r244871 - Remove superfluous private:, TypeCache is private by default.

2015-08-13 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Thu Aug 13 02:12:03 2015
New Revision: 244871

URL: http://llvm.org/viewvc/llvm-project?rev=244871&view=rev
Log:
Remove superfluous private:, TypeCache is private by default.


Modified:
cfe/trunk/lib/CodeGen/CodeGenTypes.h

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=244871&r1=244870&r2=244871&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Thu Aug 13 02:12:03 2015
@@ -158,7 +158,6 @@ class CodeGenTypes {
 
   SmallVector DeferredRecords;
   
-private:
   /// This map keeps cache of llvm::Types and maps clang::Type to
   /// corresponding llvm::Type.
   llvm::DenseMap TypeCache;


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


SV: [PATCH] D11940: don't diagnose -Wunused-parameter in virtual method or method that overrides base class method

2015-08-13 Thread Daniel Marjamäki via cfe-commits

Hello!

> If the subset of cases where this warning fires on parameters to virtual 
> functions produces more noise (if a significant % of cases just result in 
> commenting out the parameter name rather than removing the parameter) than 
> signal, it's certainly within the realm of discussion that we have about 
> whether that subset of cases is worth keeping in the warning.

yes I agree.


> (And if you don't like this warning, then don't enable it.)

I want to have warnings when the parameter is unused. I want to enable only 
those.

Personally I would appreciate if there was conservative compiler warnings that 
I could enable for -Wunused-parameter, -Wsign-compare,  that only warns 
when the code is possibly unsafe or there is unused parameter etc.

I am not saying we must remove those other warnings. I am fine that they are 
enabled separately for instance -Wunused-parameter-virtual so I can disable 
them with -Wno-unused-parameter-virtual. Or move them to the analyser or 
clang-tidy or something.


Best regards,
Daniel Marjamäki

..
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile: +46 (0)709 12 42 62
E-mail: daniel.marjam...@evidente.se

www.evidente.se


Från: tha...@google.com [tha...@google.com] för Nico Weber 
[tha...@chromium.org]
Skickat: den 12 augusti 2015 22:13
Till: David Blaikie
Kopia: Daniel Marjamäki; 
reviews+d11940+public+578c1335b27aa...@reviews.llvm.org; 
cfe-commits@lists.llvm.org
Ämne: Re: [PATCH] D11940: don't diagnose -Wunused-parameter in virtual method 
or method that overrides base class method

On Wed, Aug 12, 2015 at 11:16 AM, David Blaikie 
mailto:dblai...@gmail.com>> wrote:


On Wed, Aug 12, 2015 at 11:12 AM, Nico Weber 
mailto:tha...@chromium.org>> wrote:
On Wed, Aug 12, 2015 at 11:06 AM, David Blaikie 
mailto:dblai...@gmail.com>> wrote:


On Wed, Aug 12, 2015 at 10:11 AM, Nico Weber 
mailto:tha...@chromium.org>> wrote:
On Tue, Aug 11, 2015 at 10:15 PM, Daniel Marjamäki 
mailto:daniel.marjam...@evidente.se>> wrote:

ideally there should be no -Wunused-parameter compiler warning when the 
parameter is used.

would it feel better to move the "FP" warnings about virtual functions, for 
instance to clang-tidy?

> If you enable this warning, you probably want to know about unused 
> parameters, independent of if your function is virtual or not, no?

imho there are some compiler warnings that are too noisy. I don't like to get a 
warning when there is obviously no bug:

sign compare:
  if the signed value is obviously not negative then there is no bug:
signed x;  .. if (x>10 && x < s.size())
unused parameter:
  could check in the current translation unit if the parameter is used in an 
overloaded method.

It doesn't warn about the presence of the parameter, but about the presence of 
the name. If you say f(int, int) instead of f(int a, int b) then the warning 
won't fire.

(And if you don't like this warning, then don't enable it.)

This isn't usually the approach we take with Clang's warnings - we try to 
remove false positives (where "false positive" is usually defined as "diagnoses 
something which is not a bug" (where bug is defined as "the resulting program 
behaves in a way that the user doesn't intend/expect")) where practical.

Sure, for warnings that are supposed to find bugs. The -Wunused warnings warn 
about stuff that's unused, not bugs.

Seems a reasonable analog here, though, would be that a true positive for 
-Wunused is when the thing really is unused and should be removed. Commenting 
out the variable name is the suppression mechanism to workaround false 
positives.

I disagree with this assessment. The warning warns about unused parameter 
names. So this is a true positive.

If there's a targetable subset of cases where the s/n is low enough, it could 
be reasonable to suppress the warning in that subset, I think.

(see improvements to -Wunreachable-code to suppress cases that are unreachable 
in this build (sizeof(int) == 4 conditions, macros, etc), or represent valid 
defensive programming (default in a covered enum switch) to make the diagnostic 
more useful/less noisy)



If the subset of cases where this warning fires on parameters to virtual 
functions produces more noise (if a significant % of cases just result in 
commenting out the parameter name rather than removing the parameter) than 
signal, it's certainly within the realm of discussion that we have about 
whether that subset of cases is worth keeping in the warning.

- David


constructor initialization order:
  should not warn if the order obviously does not matter. for instance 
initialization order of pod variables using constants.
etc

Best regards,
Daniel Marjamäki

.

Re: [PATCH] D10365: Add cmd to compilation database file format

2015-08-13 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp:295
@@ +294,3 @@
+if (CommandFound) {
+  ErrorMessage = "Multiple command and arguments found";
+  return false;

You're probably right. I guess people are not distributing clang tools (yet!), 
so we probably don't need tools like cmake to output both at the same time.

What I meant with "preferred" is that we could allow specifying both, and then 
we would use 'arguments', if specified, and otherwise fall back to 'command'. 
Does that make sense?


Comment at: ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp:298-300
@@ +297,5 @@
+}
+for (auto& NextArgument : *SequenceString) {
+  SmallString<128> CommandStorage;
+  auto ValueString = dyn_cast(&NextArgument);
+

Thanks!


http://reviews.llvm.org/D10365



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


Re: [PATCH] D11944: Nativize filename in FileManager::getFile().

2015-08-13 Thread Manuel Klimek via cfe-commits
klimek added a comment.

In http://reviews.llvm.org/D11944#222975, @rsmith wrote:

> In principle, normalizing slashes on Windows makes sense here. But we 
> shouldn't use `llvm::sys::path::native`, because it's just too broken.


Ok, so if I understand you correctly it would make sense to create a normalize 
function for the file manager (it's all about the file manager's caching 
anyway).

The idea would be that on Windows we replace all / with \, otherwise we leave 
things as they are?


http://reviews.llvm.org/D11944



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


Re: [PATCH] D11946: Create clang-tidy module modernize. Add pass-by-value check.

2015-08-13 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 32036.
angelgarcia marked 4 inline comments as done.
angelgarcia added a comment.

Set IncludeStyle as an option. Fix comments.


http://reviews.llvm.org/D11946

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/Makefile
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/Makefile
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/tool/Makefile
  test/clang-tidy/modernize-pass-by-value.cpp

Index: test/clang-tidy/modernize-pass-by-value.cpp
===
--- test/clang-tidy/modernize-pass-by-value.cpp
+++ test/clang-tidy/modernize-pass-by-value.cpp
@@ -0,0 +1,197 @@
+// RUN: $(dirname %s)/check_clang_tidy.sh %s modernize-pass-by-value %t
+// REQUIRES: shell
+
+// CHECK-FIXES: #include 
+
+namespace {
+// POD types are trivially move constructible.
+struct Movable {
+  int a, b, c;
+};
+
+struct NotMovable {
+  NotMovable() = default;
+  NotMovable(const NotMovable &) = default;
+  NotMovable(NotMovable &&) = delete;
+  int a, b, c;
+};
+}
+
+struct A {
+  A(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move [modernize-pass-by-value]
+  // CHECK-FIXES: A(Movable M) : M(std::move(M)) {}
+  Movable M;
+};
+
+// Test that we aren't modifying other things than a parameter.
+Movable GlobalObj;
+struct B {
+  B(const Movable &M) : M(GlobalObj) {}
+  // CHECK-FIXES: B(const Movable &M) : M(GlobalObj) {}
+  Movable M;
+};
+
+// Test that a parameter with more than one reference to it won't be changed.
+struct C {
+  // Tests extra-reference in body.
+  C(const Movable &M) : M(M) { this->i = M.a; }
+  // CHECK-FIXES: C(const Movable &M) : M(M) { this->i = M.a; }
+
+  // Tests extra-reference in init-list.
+  C(const Movable &M, int) : M(M), i(M.a) {}
+  // CHECK-FIXES: C(const Movable &M, int) : M(M), i(M.a) {}
+  Movable M;
+  int i;
+};
+
+// Test that both declaration and definition are updated.
+struct D {
+  D(const Movable &M);
+  // CHECK-FIXES: D(Movable M);
+  Movable M;
+};
+D::D(const Movable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: D::D(Movable M) : M(std::move(M)) {}
+
+// Test with default parameter.
+struct E {
+  E(const Movable &M = Movable()) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: E(Movable M = Movable()) : M(std::move(M)) {}
+  Movable M;
+};
+
+// Test with object that can't be moved.
+struct F {
+  F(const NotMovable &NM) : NM(NM) {}
+  // CHECK-FIXES: F(const NotMovable &NM) : NM(NM) {}
+  NotMovable NM;
+};
+
+// Test unnamed parameter in declaration.
+struct G {
+  G(const Movable &);
+  // CHECK-FIXES: G(Movable );
+  Movable M;
+};
+G::G(const Movable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: G::G(Movable M) : M(std::move(M)) {}
+
+// Test parameter with and without qualifier.
+namespace ns_H {
+typedef ::Movable HMovable;
+}
+struct H {
+  H(const ns_H::HMovable &M);
+  // CHECK-FIXES: H(ns_H::HMovable M);
+  ns_H::HMovable M;
+};
+using namespace ns_H;
+H::H(const HMovable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: H(HMovable M) : M(std::move(M)) {}
+
+// Try messing up with macros.
+#define MOVABLE_PARAM(Name) const Movable & Name
+// CHECK-FIXES: #define MOVABLE_PARAM(Name) const Movable & Name
+struct I {
+  I(MOVABLE_PARAM(M)) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: I(MOVABLE_PARAM(M)) : M(M) {}
+  Movable M;
+};
+#undef MOVABLE_PARAM
+
+// Test that templates aren't modified.
+template  struct J {
+  J(const T &M) : M(M) {}
+  // CHECK-FIXES: J(const T &M) : M(M) {}
+  T M;
+};
+J j1(Movable());
+J j2(NotMovable());
+
+struct K_Movable {
+  K_Movable() = default;
+  K_Movable(const K_Movable &) = default;
+  K_Movable(K_Movable &&o) { dummy = o.dummy; }
+  int dummy;
+};
+
+// Test with movable type with an user defined move constructor.
+struct K {
+  K(const K_Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: K(K_Movable M) : M(std::move(M)) {}
+  K_Movable M;
+};
+
+template  struct L {
+  L(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: L(Movable M) : M(std::move(M)) {}
+  Movable M;
+};
+L l(Movable());
+
+// Test with a non-instantiated template class.
+template  struct N {
+  N(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: N(Movable M) : M(std::move(M)) {}
+
+  Movable M;
+  T A;
+};
+
+// Test with value p

RE: [PATCH] RE: [cfe-dev] missing return statement for non-void functions in C++

2015-08-13 Thread Sjoerd Meijer via cfe-commits
Hi Richard,
Thanks for reviewing. Agree, that was a bit confusing. More specifically,
the warning message was confusing (i.e. wrong). This patch is for compiling .c
input in C++ mode. The new flag should be ignored for C++ *input*, and indeed
not when it is in C++ *mode* as the warning message said earlier. So I have
changed the warning message accordingly and hope that solves it, see attached
patch.
Cheers.

From: meta...@gmail.com [mailto:meta...@gmail.com] On Behalf Of Richard Smith
Sent: 12 August 2015 23:06
To: Sjoerd Meijer
Cc: Hal Finkel; Marshall Clow; cfe-commits
Subject: Re: [PATCH] RE: [cfe-dev] missing return statement for non-void 
functions in C++

This patch seems a bit confused. You warn that the flag is ignored in C++, but 
it only has an effect in C++. You have a testcase with a .c extension that is 
built with -x c++.

On Wed, Aug 12, 2015 at 5:23 AM, Sjoerd Meijer 
mailto:sjoerd.mei...@arm.com>> wrote:
[ + cfe-commits@lists.llvm.org ]

Hi,
The functionality is now available under a flag, see attached patch. Note that 
the flag is ignored in C++ mode, so it will help the use case of compiling 
(legacy) C code with a C++ compiler.
Cheers,
Sjoerd.

From: Sjoerd Meijer [mailto:sjoerd.mei...@arm.com]
Sent: 03 August 2015 11:40
To: 'Richard Smith'
Cc: Hal Finkel; Marshall Clow; cfe-...@cs.uiuc.edu 
Developers; cfe commits
Subject: RE: [PATCH] RE: [cfe-dev] missing return statement for non-void 
functions in C++

Hi Richard,

I agree with your conclusions and will start preparing a patch for option 3) 
under a flag that is off by default; this enables folks to build/run C code in 
C++. I actually think option 2) would be a good one too, but as it is already 
available under a flag I also don’t see how useful it is combining options 2) 
and 3) with another (or one more) flag that is off by default.

Cheers.

From: meta...@gmail.com [mailto:meta...@gmail.com] On 
Behalf Of Richard Smith
Sent: 31 July 2015 19:46
To: Sjoerd Meijer
Cc: Hal Finkel; Marshall Clow; cfe-...@cs.uiuc.edu 
Developers; cfe commits
Subject: Re: [PATCH] RE: [cfe-dev] missing return statement for non-void 
functions in C++

On Fri, Jul 31, 2015 at 7:35 AM, Sjoerd Meijer 
mailto:sjoerd.mei...@arm.com>> wrote:
Hi, I am not sure if we came to a conclusion. Please find attached a patch. It 
simply removes the two lines that insert an unreachable statement (which cause 
removal of the return statement). Please note that at -O0 the trap instruction 
is still generated. Is this something we could live with?

I don't think this is an improvement:

This doesn't satisfy the folks who want an 'unreachable' for better code size 
and optimization, and it doesn't satisfy the folks who want a guaranteed trap 
for security, and it doesn't satisfy the folks who want their broken code to 
limp along (because it'll still trap at -O0), and it is at best a minor 
improvement for the folks who want missing returns to be more easily debuggable 
(with -On, the code goes wrong in the caller, or appears to work, rather than 
falling into an unrelated function, and debugging this with -O0 was already 
easy).

I think there are three options that are defensible here:
1) The status quo: this is UB and we treat it as such and optimize on that 
basis, but provide a trap as a convenience at -O0
2) The secure approach: this is UB but we always trap
3) Define the behavior to return 'undef' for C types: this allows questionable 
C code that has UB in C++ to keep working when built with a C++ compiler

Note that (3) can be combined with either (1) or (2). (2) is already available 
via the 'return' sanitizer. So this really reduces to: in those cases where C 
says it's OK so long as the caller doesn't look at the returned value (and 
where the return type doesn't have a non-trivial copy constructor or 
destructor, isn't a reference, and so on), should we attempt to preserve the C 
behaviour? I would be OK with putting that behind a `-f` flag (perhaps 
`-fstrict-return` or similar) to support those folks who want to build C code 
in C++, but I would suggest having that flag be off by default, since that is 
not the usual use case for a C++ compiler.

Cheers,
Sjoerd.

From: cfe-dev-boun...@cs.uiuc.edu 
[mailto:cfe-dev-boun...@cs.uiuc.edu] On 
Behalf Of Richard Smith
Sent: 29 July 2015 18:07
To: Hal Finkel
Cc: Marshall Clow; cfe-...@cs.uiuc.edu Developers

Subject: Re: [cfe-dev] missing return statement for non-void functions in C++


On Jul 29, 2015 7:43 AM, "Hal Finkel" mailto:hfin...@anl.gov>> 
wrote:
>
> - Original Message -
> > From: "David Blaikie" mailto:dblai...@gmail.com>>
> > To: "James Molloy" mailto:ja...@jamesmolloy.co.uk>>
> > Cc: "Marshall Clow" mailto:mclow.li...@gmail.com>>, 
> > "cfe-dev Developers" mailto:cfe-...@cs.uiuc.edu>

Re: [PATCH] D11944: Nativize filename in FileManager::getFile().

2015-08-13 Thread Yaron Keren via cfe-commits
yaron.keren added inline comments.


Comment at: lib/Basic/FileManager.cpp:221-222
@@ -220,1 +220,4 @@
 
+  SmallString<1024> NativeFilename;
+  llvm::sys::path::native(Filename, NativeFilename);
+

rsmith wrote:
> I have two concerns with this:
> 
> 1) It's needlessly inefficient on non-Win32 platforms (we'll make an 
> unnecessary string copy)
> 2) It does something bizarre and wrong on non-Win32 platforms (it converts 
> `\` to `/` unless the `\` is followed by another `\`, making most files 
> containing `\` inaccessible)
2 is surprising. Any idea why native does this on non-Windows platforms?



http://reviews.llvm.org/D11944



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


[clang-tools-extra] r244876 - Fix formatting.

2015-08-13 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Thu Aug 13 04:09:28 2015
New Revision: 244876

URL: http://llvm.org/viewvc/llvm-project?rev=244876&view=rev
Log:
Fix formatting.

Modified:
clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h

Modified: clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h?rev=244876&r1=244875&r2=244876&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h (original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyTest.h Thu Aug 13 
04:09:28 2015
@@ -78,7 +78,7 @@ runCheckOnCode(StringRef Code, std::vect
   Invocation.setDiagnosticConsumer(&DiagConsumer);
   if (!Invocation.run()) {
 std::string ErrorText;
-for (const auto &Error:Context.getErrors()) {
+for (const auto &Error : Context.getErrors()) {
   ErrorText += Error.Message.Message + "\n";
 }
 llvm::report_fatal_error(ErrorText);


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


Re: [PATCH] D11944: Nativize filename in FileManager::getFile().

2015-08-13 Thread NAKAMURA Takumi via cfe-commits
chapuni added a comment.

I wish, in clang/llvm, internal path separator would be slash.
It'd be better to use backslash where it'd be really required, for example 
interface to cmd.exe or MS toolchain.

For me, native-ization is nightmare.


http://reviews.llvm.org/D11944



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


Re: r244867 - Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.

2015-08-13 Thread Renato Golin via cfe-commits
On 13 August 2015 at 07:15, Yaron Keren via cfe-commits
 wrote:
> CHECK-EIGHT is failing bots, see
>
> http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24306/steps/check-all/logs/FAIL%3A%20Clang%3A%3Adependency-gen.c


That check only works if compiler-rt is built in, and supports the
target. I wouldn't put that in a Clang test.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-13 Thread Andrey Bokhanko via cfe-commits
andreybokhanko added a comment.

John,

Thank you for the quick reply!

Let me make sure I understand what you said, using my test as an example (BTW, 
sorry if this is a dumb question -- I asked our local Clang experts, but no-one 
seems to be 100% sure what to do):

  1: struct T {
  2:   ~T() {}
  3: };
  4: 
  5: extern "C" void _ZN1TD1Ev();
  6: 
  7: int main() {
  8:   _ZN1TD1Ev();
  9:   T t;
  10: }

When we deal with the call at line N8, there are no Functions created yet, so 
nothing to bitcast. Thus, we create a Function and the following call:

  call void @_ZN1TD1Ev()

When we deal with implicit destructor call at line N10, there is already a 
Function with "_ZN1TD1Ev" mangled name exists. Thus, we create a bitcast and 
the following call:

  call void bitcast (void ()* @_ZN1TD1Ev to void (%struct.T*)*)(%struct.T* %t)

At the end of IRGen we should replace all references of old _ZN1TD1Ev (one with 
zero arguments) with new _ZN1TD1Ev (one with a single T* argument) -- 
*including* adding a new bitcast (as we replace a Function with different type) 
in all places in IR where we do the replacement.

Is my understanding correct?

Andrey


http://reviews.llvm.org/D11297



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


Re: [PATCH] D11944: Nativize filename in FileManager::getFile().

2015-08-13 Thread Manuel Klimek via cfe-commits
klimek added a comment.

In http://reviews.llvm.org/D11944#223597, @chapuni wrote:

> I wish, in clang/llvm, internal path separator would be slash.
>  It'd be better to use backslash where it'd be really required, for example 
> interface to cmd.exe or MS toolchain.
>
> For me, native-ization is nightmare.


Are you saying that all MS functions we access support / as path separator on 
the platforms we support, or that we should canonicalize all filenames to / 
when we first get them, and convert them to \-based when we hit the MS file 
APIs?


http://reviews.llvm.org/D11944



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


Re: [PATCH] D11944: Nativize filename in FileManager::getFile().

2015-08-13 Thread Yaron Keren via cfe-commits
yaron.keren added a comment.

I think she wishes your second option.

Note that windows API actually do accept slash as seperator and need no 
conversion.

  
https://en.wikipedia.org/wiki/Path_(computing)#MS-DOS.2FMicrosoft_Windows_style

The issues are with apps that interpret slash as switch, mainly the VC 
toolchain and with humans that may expect to see backward slashes. Not all apps 
do. Windows ports of the gnu utils accept slash just fine, so both

  ls ../test
  ls ..\test

work running from cmd.exe. So lit tests can continue to use slash unless they 
call the real VC toolchain (in which case they can't run on non-Windows anyhow).

As for the humans, while it may make sense to backward-slash paths when 
printing diagnostics, the current output is a mix of 
whatever-was-used-as-input, slashes and backslahses depending on the code path 
so any standardization - slash or backslash - would be better.

Overall, this makes sense and will simplify code and tests.


http://reviews.llvm.org/D11944



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


r244888 - Remove raw_svector_ostream::resync and users. It's no-op after r244870.

2015-08-13 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Thu Aug 13 07:42:25 2015
New Revision: 244888

URL: http://llvm.org/viewvc/llvm-project?rev=244888&view=rev
Log:
Remove raw_svector_ostream::resync and users. It's no-op after r244870.


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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=244888&r1=244887&r2=244888&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Aug 13 07:42:25 2015
@@ -6780,9 +6780,7 @@ static bool extractFieldType(SmallVector
 if (Field->isBitField()) {
   Enc += "b(";
   llvm::raw_svector_ostream OS(Enc);
-  OS.resync();
   OS << Field->getBitWidthValue(CGM.getContext());
-  OS.flush();
   Enc += ':';
 }
 if (!appendType(Enc, Field->getType(), CGM, TSC))


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


Re: [PATCH] D11948: Add some macros to abstract marking of parameters as "not null", and use them in

2015-08-13 Thread Joerg Sonnenberger via cfe-commits
On Wed, Aug 12, 2015 at 07:18:05PM -0500, Hal Finkel via cfe-commits wrote:
> I could say the same thing about many optimizations -- I spend a lot
> of time tracking down bugs they expose -- the real thing to investigate
> here are the potential benefits to real code from performing the
> optimization. I'm generally in favor of these kinds of optimizations
> because they tend to lower abstraction penalties, but actual data here
> would be helpful.

I would be interested in real world examples where this optimisation is
benefical. This one seems to be especially obnoxious as it forces
additional branches for portable code.

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


r244890 - clang-format: Fix incorrect lambda-detection.

2015-08-13 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Thu Aug 13 08:37:08 2015
New Revision: 244890

URL: http://llvm.org/viewvc/llvm-project?rev=244890&view=rev
Log:
clang-format: Fix incorrect lambda-detection.

Before:
  [ a, a ]() -> a<1>{};

After:
  [a, a]() -> a<1> {};

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=244890&r1=244889&r2=244890&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Aug 13 08:37:08 2015
@@ -1000,6 +1000,7 @@ bool UnwrappedLineParser::tryToParseLamb
 case tok::less:
 case tok::greater:
 case tok::identifier:
+case tok::numeric_constant:
 case tok::coloncolon:
 case tok::kw_mutable:
   nextToken();

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=244890&r1=244889&r2=244890&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Aug 13 08:37:08 2015
@@ -10003,6 +10003,7 @@ TEST_F(FormatTest, FormatsLambdas) {
   verifyGoogleFormat("auto a = [&b, c](D* d) -> pair {};");
   verifyGoogleFormat("auto a = [&b, c](D* d) -> D& {};");
   verifyGoogleFormat("auto a = [&b, c](D* d) -> const D* {};");
+  verifyFormat("[a, a]() -> a<1> {};");
   verifyFormat("auto  = [](int i, // break for some reason\n"
"   int j) -> int {\n"
"  return (i * 
j);\n"


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


r244891 - clang-format: Inside decltype(), there is an expression.

2015-08-13 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Thu Aug 13 08:43:51 2015
New Revision: 244891

URL: http://llvm.org/viewvc/llvm-project?rev=244891&view=rev
Log:
clang-format: Inside decltype(), there is an expression.

Before:
  decltype(a* b) F();

After:
  decltype(a * b) F();

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=244891&r1=244890&r2=244891&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Aug 13 08:43:51 2015
@@ -120,8 +120,9 @@ private:
 }
 
 if (Left->Previous &&
-(Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_if,
- tok::kw_while, tok::l_paren, tok::comma) ||
+(Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype,
+ tok::kw_if, tok::kw_while, tok::l_paren,
+ tok::comma) ||
  Left->Previous->is(TT_BinaryOperator))) {
   // static_assert, if and while usually contain expressions.
   Contexts.back().IsExpression = true;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=244891&r1=244890&r2=244891&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Aug 13 08:43:51 2015
@@ -5408,6 +5408,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
   verifyFormat("auto PointerBinding = [](const char *S) {};");
   verifyFormat("typedef typeof(int(int, int)) *MyFunc;");
   verifyFormat("[](const decltype(*a) &value) {}");
+  verifyFormat("decltype(a * b) F();");
   verifyFormat("#define MACRO() [](A *a) { return 1; }");
   verifyIndependentOfContext("typedef void (*f)(int *a);");
   verifyIndependentOfContext("int i{a * b};");


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


[libunwind] r244892 - Correct sense of unwind return address register range assertion

2015-08-13 Thread Ed Maste via cfe-commits
Author: emaste
Date: Thu Aug 13 08:45:45 2015
New Revision: 244892

URL: http://llvm.org/viewvc/llvm-project?rev=244892&view=rev
Log:
Correct sense of unwind return address register range assertion

I encountered this on FreeBSD/arm64, and then found the same issue was
reported by Daniil Troshkov.

Modified:
libunwind/trunk/src/DwarfInstructions.hpp

Modified: libunwind/trunk/src/DwarfInstructions.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=244892&r1=244891&r2=244892&view=diff
==
--- libunwind/trunk/src/DwarfInstructions.hpp (original)
+++ libunwind/trunk/src/DwarfInstructions.hpp Thu Aug 13 08:45:45 2015
@@ -170,7 +170,7 @@ int DwarfInstructions::stepWithDwa
   const int lastReg = R::lastDwarfRegNum();
   assert((int)CFI_Parser::kMaxRegisterNumber > lastReg &&
  "register range too large");
-  assert(lastReg <= (int)cieInfo.returnAddressRegister &&
+  assert(lastReg >= (int)cieInfo.returnAddressRegister &&
  "register range does not contain return address register");
   for (int i = 0; i <= lastReg; ++i) {
 if (prolog.savedRegisters[i].location !=


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


Re: [PATCH] D11948: Add some macros to abstract marking of parameters as "not null", and use them in

2015-08-13 Thread Marshall Clow via cfe-commits
On Wed, Aug 12, 2015 at 4:03 PM, Dan Albert  wrote:

> My testing was varied. I could not get GCC or clang to optimize it away
> for Linux, but both did for ARM Android.
>

Then I don't understand your objection to this change, then.

On your platform, the effect of this change is (therefore) a compile-time
warning when you pass (a constant) NULL to a set of functions that are
documented to require non-null parameters.

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


[libunwind] r244893 - Enable zero-cost exceptions on non-Apple arm64 platforms

2015-08-13 Thread Ed Maste via cfe-commits
Author: emaste
Date: Thu Aug 13 09:21:03 2015
New Revision: 244893

URL: http://llvm.org/viewvc/llvm-project?rev=244893&view=rev
Log:
Enable zero-cost exceptions on non-Apple arm64 platforms

Use the canonical __aarch64__ predefined macro for 64-bit ARM. Apple-
specific cases are left as __arm64__. Also add an #error for unsupported
architectures to catch this sort of case in the future.

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

Modified:
libunwind/trunk/src/config.h
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=244893&r1=244892&r2=244893&view=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Thu Aug 13 09:21:03 2015
@@ -72,7 +72,8 @@
 
   #define _LIBUNWIND_BUILD_ZERO_COST_APIS (defined(__i386__) || \
defined(__x86_64__) || \
-   defined(__arm__))
+   defined(__arm__) || \
+   defined(__aarch64__))
   #define _LIBUNWIND_BUILD_SJLJ_APIS  0
   #define _LIBUNWIND_SUPPORT_FRAME_APIS   (defined(__i386__) || \
defined(__x86_64__))

Modified: libunwind/trunk/src/libunwind.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/libunwind.cpp?rev=244893&r1=244892&r2=244893&view=diff
==
--- libunwind/trunk/src/libunwind.cpp (original)
+++ libunwind/trunk/src/libunwind.cpp Thu Aug 13 09:21:03 2015
@@ -58,12 +58,14 @@ _LIBUNWIND_EXPORT int unw_init_local(unw
 #elif defined(__ppc__)
   new ((void *)cursor) UnwindCursor(
  context, 
LocalAddressSpace::sThisAddressSpace);
-#elif defined(__arm64__)
+#elif defined(__arm64__) || defined(__aarch64__)
   new ((void *)cursor) UnwindCursor(
  context, 
LocalAddressSpace::sThisAddressSpace);
 #elif _LIBUNWIND_ARM_EHABI
   new ((void *)cursor) UnwindCursor(
  context, 
LocalAddressSpace::sThisAddressSpace);
+#else
+#error Architecture not supported
 #endif
   AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
   co->setInfoBasedOnIPRegister();


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


Re: [PATCH] D7642: Introduce the idea of a minimum libc version

2015-08-13 Thread David Majnemer via cfe-commits
majnemer added a comment.

In http://reviews.llvm.org/D7642#223489, @compnerd wrote:

> Okay, if thats the general pattern, then we can stick it in the triple.  
> Though, that means that the use of the triple for determining the MS 
> compatibility needs to be undone.  If the version in the triple is the libc 
> version, then it can differ from the MS compatibility version.  The target 
> platform may be different from the compiler version (IIRC, thats the 
> terminology that Visual Studio uses).


Before VS 2013, Visual C++ shiped a msvcrt and compiler in tandem which would 
mean that the version of the compiler and library should be the same, no?

After VS 2013, things get a bit more confusing. There is ucrt which lives in 
the PSDK + msvcrt which lives in the MSVC SDK.

If I understand things correctly, the following are true:

- ucrt forms a stable interface, no exported functions can be removed
- ucrt could, in theory, grow additional functionality
- msvcrt will continue to change but must assume a base line ucrt, it might 
have to work with the ucrt included with Windows 10 many years after the fact

AFAICT, the compiler is only concerned about the version-to-version contents of 
msvcrt and not ucrt because ucrt is essentially unchanging.  This indicates, to 
me, that we are still concerned with the compiler version.


Repository:
  rL LLVM

http://reviews.llvm.org/D7642



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


Re: [PATCH] D11946: Create clang-tidy module modernize. Add pass-by-value check.

2015-08-13 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Thanks for the updates.

Looks good with a couple of nits.



Comment at: clang-tidy/modernize/PassByValueCheck.cpp:83
@@ +82,3 @@
+   public:
+ExactlyOneUsageVisitor(const ParmVarDecl *ParamDecl) : 
ParamDecl(ParamDecl) {}
+

80 columns limit is exceeded here and below. The whole class is over-indented. 
Please run clang-tidy on the file.


Comment at: clang-tidy/modernize/PassByValueCheck.cpp:131
@@ +130,3 @@
+  : ClangTidyCheck(Name, Context) {
+std::string IncludeStyleStr = Options.get("IncludeStyle", "llvm");
+if (IncludeStyleStr == "llvm") {

Please use `llvm::StringSwitch`.


http://reviews.llvm.org/D11946



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


Re: [PATCH] D11946: Create clang-tidy module modernize. Add pass-by-value check.

2015-08-13 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/PassByValueCheck.cpp:131
@@ +130,3 @@
+  : ClangTidyCheck(Name, Context) {
+std::string IncludeStyleStr = Options.get("IncludeStyle", "llvm");
+if (IncludeStyleStr == "llvm") {

alexfh wrote:
> Please use `llvm::StringSwitch`.
Also, please make `IncludeStyle` const and initialize it in the constructor 
initializer list.


http://reviews.llvm.org/D11946



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


Re: [PATCH] D11946: Create clang-tidy module modernize. Add pass-by-value check.

2015-08-13 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 32055.
angelgarcia marked 3 inline comments as done.
angelgarcia added a comment.

Make IncludeStyle constant, initialize it with StringSwitch. Fix indentation.


http://reviews.llvm.org/D11946

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/Makefile
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/Makefile
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/tool/Makefile
  test/clang-tidy/modernize-pass-by-value.cpp

Index: test/clang-tidy/modernize-pass-by-value.cpp
===
--- test/clang-tidy/modernize-pass-by-value.cpp
+++ test/clang-tidy/modernize-pass-by-value.cpp
@@ -0,0 +1,197 @@
+// RUN: $(dirname %s)/check_clang_tidy.sh %s modernize-pass-by-value %t
+// REQUIRES: shell
+
+// CHECK-FIXES: #include 
+
+namespace {
+// POD types are trivially move constructible.
+struct Movable {
+  int a, b, c;
+};
+
+struct NotMovable {
+  NotMovable() = default;
+  NotMovable(const NotMovable &) = default;
+  NotMovable(NotMovable &&) = delete;
+  int a, b, c;
+};
+}
+
+struct A {
+  A(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move [modernize-pass-by-value]
+  // CHECK-FIXES: A(Movable M) : M(std::move(M)) {}
+  Movable M;
+};
+
+// Test that we aren't modifying other things than a parameter.
+Movable GlobalObj;
+struct B {
+  B(const Movable &M) : M(GlobalObj) {}
+  // CHECK-FIXES: B(const Movable &M) : M(GlobalObj) {}
+  Movable M;
+};
+
+// Test that a parameter with more than one reference to it won't be changed.
+struct C {
+  // Tests extra-reference in body.
+  C(const Movable &M) : M(M) { this->i = M.a; }
+  // CHECK-FIXES: C(const Movable &M) : M(M) { this->i = M.a; }
+
+  // Tests extra-reference in init-list.
+  C(const Movable &M, int) : M(M), i(M.a) {}
+  // CHECK-FIXES: C(const Movable &M, int) : M(M), i(M.a) {}
+  Movable M;
+  int i;
+};
+
+// Test that both declaration and definition are updated.
+struct D {
+  D(const Movable &M);
+  // CHECK-FIXES: D(Movable M);
+  Movable M;
+};
+D::D(const Movable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: D::D(Movable M) : M(std::move(M)) {}
+
+// Test with default parameter.
+struct E {
+  E(const Movable &M = Movable()) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: E(Movable M = Movable()) : M(std::move(M)) {}
+  Movable M;
+};
+
+// Test with object that can't be moved.
+struct F {
+  F(const NotMovable &NM) : NM(NM) {}
+  // CHECK-FIXES: F(const NotMovable &NM) : NM(NM) {}
+  NotMovable NM;
+};
+
+// Test unnamed parameter in declaration.
+struct G {
+  G(const Movable &);
+  // CHECK-FIXES: G(Movable );
+  Movable M;
+};
+G::G(const Movable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: G::G(Movable M) : M(std::move(M)) {}
+
+// Test parameter with and without qualifier.
+namespace ns_H {
+typedef ::Movable HMovable;
+}
+struct H {
+  H(const ns_H::HMovable &M);
+  // CHECK-FIXES: H(ns_H::HMovable M);
+  ns_H::HMovable M;
+};
+using namespace ns_H;
+H::H(const HMovable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: H(HMovable M) : M(std::move(M)) {}
+
+// Try messing up with macros.
+#define MOVABLE_PARAM(Name) const Movable & Name
+// CHECK-FIXES: #define MOVABLE_PARAM(Name) const Movable & Name
+struct I {
+  I(MOVABLE_PARAM(M)) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: I(MOVABLE_PARAM(M)) : M(M) {}
+  Movable M;
+};
+#undef MOVABLE_PARAM
+
+// Test that templates aren't modified.
+template  struct J {
+  J(const T &M) : M(M) {}
+  // CHECK-FIXES: J(const T &M) : M(M) {}
+  T M;
+};
+J j1(Movable());
+J j2(NotMovable());
+
+struct K_Movable {
+  K_Movable() = default;
+  K_Movable(const K_Movable &) = default;
+  K_Movable(K_Movable &&o) { dummy = o.dummy; }
+  int dummy;
+};
+
+// Test with movable type with an user defined move constructor.
+struct K {
+  K(const K_Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: K(K_Movable M) : M(std::move(M)) {}
+  K_Movable M;
+};
+
+template  struct L {
+  L(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: L(Movable M) : M(std::move(M)) {}
+  Movable M;
+};
+L l(Movable());
+
+// Test with a non-instantiated template class.
+template  struct N {
+  N(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: N(Movable M) : M(std::move(M)) {}
+
+  Movable M;
+ 

Re: [PATCH] D11946: Create clang-tidy module modernize. Add pass-by-value check.

2015-08-13 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/PassByValueCheck.cpp:134
@@ +133,3 @@
+: ClangTidyCheck(Name, Context),
+  IncludeStyle(StringSwitch(
+   Options.get("IncludeStyle", "llvm"))

Thinking a bit more of this, with just two values a conditional operator seems 
to be better than a StringSwitch.


http://reviews.llvm.org/D11946



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


Re: [PATCH] D11946: Create clang-tidy module modernize. Add pass-by-value check.

2015-08-13 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 32059.
angelgarcia added a comment.

Remove StringSwitch.


http://reviews.llvm.org/D11946

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/Makefile
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/Makefile
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/tool/Makefile
  test/clang-tidy/modernize-pass-by-value.cpp

Index: test/clang-tidy/modernize-pass-by-value.cpp
===
--- test/clang-tidy/modernize-pass-by-value.cpp
+++ test/clang-tidy/modernize-pass-by-value.cpp
@@ -0,0 +1,197 @@
+// RUN: $(dirname %s)/check_clang_tidy.sh %s modernize-pass-by-value %t
+// REQUIRES: shell
+
+// CHECK-FIXES: #include 
+
+namespace {
+// POD types are trivially move constructible.
+struct Movable {
+  int a, b, c;
+};
+
+struct NotMovable {
+  NotMovable() = default;
+  NotMovable(const NotMovable &) = default;
+  NotMovable(NotMovable &&) = delete;
+  int a, b, c;
+};
+}
+
+struct A {
+  A(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move [modernize-pass-by-value]
+  // CHECK-FIXES: A(Movable M) : M(std::move(M)) {}
+  Movable M;
+};
+
+// Test that we aren't modifying other things than a parameter.
+Movable GlobalObj;
+struct B {
+  B(const Movable &M) : M(GlobalObj) {}
+  // CHECK-FIXES: B(const Movable &M) : M(GlobalObj) {}
+  Movable M;
+};
+
+// Test that a parameter with more than one reference to it won't be changed.
+struct C {
+  // Tests extra-reference in body.
+  C(const Movable &M) : M(M) { this->i = M.a; }
+  // CHECK-FIXES: C(const Movable &M) : M(M) { this->i = M.a; }
+
+  // Tests extra-reference in init-list.
+  C(const Movable &M, int) : M(M), i(M.a) {}
+  // CHECK-FIXES: C(const Movable &M, int) : M(M), i(M.a) {}
+  Movable M;
+  int i;
+};
+
+// Test that both declaration and definition are updated.
+struct D {
+  D(const Movable &M);
+  // CHECK-FIXES: D(Movable M);
+  Movable M;
+};
+D::D(const Movable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: D::D(Movable M) : M(std::move(M)) {}
+
+// Test with default parameter.
+struct E {
+  E(const Movable &M = Movable()) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: E(Movable M = Movable()) : M(std::move(M)) {}
+  Movable M;
+};
+
+// Test with object that can't be moved.
+struct F {
+  F(const NotMovable &NM) : NM(NM) {}
+  // CHECK-FIXES: F(const NotMovable &NM) : NM(NM) {}
+  NotMovable NM;
+};
+
+// Test unnamed parameter in declaration.
+struct G {
+  G(const Movable &);
+  // CHECK-FIXES: G(Movable );
+  Movable M;
+};
+G::G(const Movable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: G::G(Movable M) : M(std::move(M)) {}
+
+// Test parameter with and without qualifier.
+namespace ns_H {
+typedef ::Movable HMovable;
+}
+struct H {
+  H(const ns_H::HMovable &M);
+  // CHECK-FIXES: H(ns_H::HMovable M);
+  ns_H::HMovable M;
+};
+using namespace ns_H;
+H::H(const HMovable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: H(HMovable M) : M(std::move(M)) {}
+
+// Try messing up with macros.
+#define MOVABLE_PARAM(Name) const Movable & Name
+// CHECK-FIXES: #define MOVABLE_PARAM(Name) const Movable & Name
+struct I {
+  I(MOVABLE_PARAM(M)) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: I(MOVABLE_PARAM(M)) : M(M) {}
+  Movable M;
+};
+#undef MOVABLE_PARAM
+
+// Test that templates aren't modified.
+template  struct J {
+  J(const T &M) : M(M) {}
+  // CHECK-FIXES: J(const T &M) : M(M) {}
+  T M;
+};
+J j1(Movable());
+J j2(NotMovable());
+
+struct K_Movable {
+  K_Movable() = default;
+  K_Movable(const K_Movable &) = default;
+  K_Movable(K_Movable &&o) { dummy = o.dummy; }
+  int dummy;
+};
+
+// Test with movable type with an user defined move constructor.
+struct K {
+  K(const K_Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: K(K_Movable M) : M(std::move(M)) {}
+  K_Movable M;
+};
+
+template  struct L {
+  L(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: L(Movable M) : M(std::move(M)) {}
+  Movable M;
+};
+L l(Movable());
+
+// Test with a non-instantiated template class.
+template  struct N {
+  N(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: N(Movable M) : M(std::move(M)) {}
+
+  Movable M;
+  T A;
+};
+
+// Test with value parameter.
+struct O {
+  O(Movable M) : M(M) {}
+  // CHECK-MESSAGES: 

Re: [PATCH] D11946: Create clang-tidy module modernize. Add pass-by-value check.

2015-08-13 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/PassByValueCheck.cpp:87
@@ +86,3 @@
+/// \brief Whether or not the parameter variable is referred only once in
+/// the
+/// given constructor.

nit: clang-format doesn't properly reflow comments, it just breaks long lines, 
so it sometimes needs manual cleanup (or gq in vim).


Comment at: clang-tidy/modernize/PassByValueCheck.cpp:134
@@ +133,3 @@
+: ClangTidyCheck(Name, Context),
+  IncludeStyle(StringSwitch(
+   Options.get("IncludeStyle", "llvm") == "llvm" ?

Does this compile?


http://reviews.llvm.org/D11946



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


Re: [PATCH] D11946: Create clang-tidy module modernize. Add pass-by-value check.

2015-08-13 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 32061.
angelgarcia added a comment.

Remove StringSwitch.


http://reviews.llvm.org/D11946

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/Makefile
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/Makefile
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/PassByValueCheck.cpp
  clang-tidy/modernize/PassByValueCheck.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/tool/Makefile
  test/clang-tidy/modernize-pass-by-value.cpp

Index: test/clang-tidy/modernize-pass-by-value.cpp
===
--- test/clang-tidy/modernize-pass-by-value.cpp
+++ test/clang-tidy/modernize-pass-by-value.cpp
@@ -0,0 +1,197 @@
+// RUN: $(dirname %s)/check_clang_tidy.sh %s modernize-pass-by-value %t
+// REQUIRES: shell
+
+// CHECK-FIXES: #include 
+
+namespace {
+// POD types are trivially move constructible.
+struct Movable {
+  int a, b, c;
+};
+
+struct NotMovable {
+  NotMovable() = default;
+  NotMovable(const NotMovable &) = default;
+  NotMovable(NotMovable &&) = delete;
+  int a, b, c;
+};
+}
+
+struct A {
+  A(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move [modernize-pass-by-value]
+  // CHECK-FIXES: A(Movable M) : M(std::move(M)) {}
+  Movable M;
+};
+
+// Test that we aren't modifying other things than a parameter.
+Movable GlobalObj;
+struct B {
+  B(const Movable &M) : M(GlobalObj) {}
+  // CHECK-FIXES: B(const Movable &M) : M(GlobalObj) {}
+  Movable M;
+};
+
+// Test that a parameter with more than one reference to it won't be changed.
+struct C {
+  // Tests extra-reference in body.
+  C(const Movable &M) : M(M) { this->i = M.a; }
+  // CHECK-FIXES: C(const Movable &M) : M(M) { this->i = M.a; }
+
+  // Tests extra-reference in init-list.
+  C(const Movable &M, int) : M(M), i(M.a) {}
+  // CHECK-FIXES: C(const Movable &M, int) : M(M), i(M.a) {}
+  Movable M;
+  int i;
+};
+
+// Test that both declaration and definition are updated.
+struct D {
+  D(const Movable &M);
+  // CHECK-FIXES: D(Movable M);
+  Movable M;
+};
+D::D(const Movable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: D::D(Movable M) : M(std::move(M)) {}
+
+// Test with default parameter.
+struct E {
+  E(const Movable &M = Movable()) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: E(Movable M = Movable()) : M(std::move(M)) {}
+  Movable M;
+};
+
+// Test with object that can't be moved.
+struct F {
+  F(const NotMovable &NM) : NM(NM) {}
+  // CHECK-FIXES: F(const NotMovable &NM) : NM(NM) {}
+  NotMovable NM;
+};
+
+// Test unnamed parameter in declaration.
+struct G {
+  G(const Movable &);
+  // CHECK-FIXES: G(Movable );
+  Movable M;
+};
+G::G(const Movable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: G::G(Movable M) : M(std::move(M)) {}
+
+// Test parameter with and without qualifier.
+namespace ns_H {
+typedef ::Movable HMovable;
+}
+struct H {
+  H(const ns_H::HMovable &M);
+  // CHECK-FIXES: H(ns_H::HMovable M);
+  ns_H::HMovable M;
+};
+using namespace ns_H;
+H::H(const HMovable &M) : M(M) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
+// CHECK-FIXES: H(HMovable M) : M(std::move(M)) {}
+
+// Try messing up with macros.
+#define MOVABLE_PARAM(Name) const Movable & Name
+// CHECK-FIXES: #define MOVABLE_PARAM(Name) const Movable & Name
+struct I {
+  I(MOVABLE_PARAM(M)) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: I(MOVABLE_PARAM(M)) : M(M) {}
+  Movable M;
+};
+#undef MOVABLE_PARAM
+
+// Test that templates aren't modified.
+template  struct J {
+  J(const T &M) : M(M) {}
+  // CHECK-FIXES: J(const T &M) : M(M) {}
+  T M;
+};
+J j1(Movable());
+J j2(NotMovable());
+
+struct K_Movable {
+  K_Movable() = default;
+  K_Movable(const K_Movable &) = default;
+  K_Movable(K_Movable &&o) { dummy = o.dummy; }
+  int dummy;
+};
+
+// Test with movable type with an user defined move constructor.
+struct K {
+  K(const K_Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: K(K_Movable M) : M(std::move(M)) {}
+  K_Movable M;
+};
+
+template  struct L {
+  L(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: L(Movable M) : M(std::move(M)) {}
+  Movable M;
+};
+L l(Movable());
+
+// Test with a non-instantiated template class.
+template  struct N {
+  N(const Movable &M) : M(M) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
+  // CHECK-FIXES: N(Movable M) : M(std::move(M)) {}
+
+  Movable M;
+  T A;
+};
+
+// Test with value parameter.
+struct O {
+  O(Movable M) : M(M) {}
+  // CHECK-MESSAGES: 

r244902 - Driver: Fix include directories when not using libgcc under mingw

2015-08-13 Thread Martell Malone via cfe-commits
Author: martell
Date: Thu Aug 13 10:41:04 2015
New Revision: 244902

URL: http://llvm.org/viewvc/llvm-project?rev=244902&view=rev
Log:
Driver: Fix include directories when not using libgcc under mingw

Summary:
When we want to use mingw-w64 and clang with compiler-rt we should not
need to have libgcc installed. This fixes finding includes when libgcc
is not installed

Reviewers: yaron.keren

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Driver/Inputs/mingw_clang_tree/
cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/
cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/

cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/

cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep
cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/
cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep
Modified:
cfe/trunk/lib/Driver/MinGWToolChain.cpp
cfe/trunk/test/Driver/mingw.cpp

Modified: cfe/trunk/lib/Driver/MinGWToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MinGWToolChain.cpp?rev=244902&r1=244901&r2=244902&view=diff
==
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp Thu Aug 13 10:41:04 2015
@@ -47,7 +47,7 @@ void MinGW::findGccLibDir() {
   Archs.emplace_back(getTriple().getArchName());
   Archs[0] += "-w64-mingw32";
   Archs.emplace_back("mingw32");
-  Arch = "unknown";
+  Arch = Archs[0].str();
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {

Added: 
cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep?rev=244902&view=auto
==
(empty)

Added: cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep?rev=244902&view=auto
==
(empty)

Modified: cfe/trunk/test/Driver/mingw.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw.cpp?rev=244902&r1=244901&r2=244902&view=diff
==
--- cfe/trunk/test/Driver/mingw.cpp (original)
+++ cfe/trunk/test/Driver/mingw.cpp Thu Aug 13 10:41:04 2015
@@ -1,3 +1,8 @@
+// RUN: %clang -target i686-windows-gnu -c -### 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_CLANG_TREE %s
+// CHECK_MINGW_CLANG_TREE: 
"{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
+// CHECK_MINGW_CLANG_TREE: 
"{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}include"
+
+
 // RUN: %clang -target i686-pc-windows-gnu -stdlib=libstdc++ -c -### 
--sysroot=%S/Inputs/mingw_mingw_org_tree/mingw %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_ORG_TREE %s
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"


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


Re: [PATCH] D11808: Driver: Fix include and lib dirs when not using gcc under mingw

2015-08-13 Thread Martell Malone via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL244902: Driver: Fix include directories when not using 
libgcc under mingw (authored by martell).

Changed prior to commit:
  http://reviews.llvm.org/D11808?vs=32007&id=32062#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11808

Files:
  cfe/trunk/lib/Driver/MinGWToolChain.cpp
  
cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/i686-w64-mingw32/include/.keep
  cfe/trunk/test/Driver/Inputs/mingw_clang_tree/mingw32/include/.keep
  cfe/trunk/test/Driver/mingw.cpp

Index: cfe/trunk/test/Driver/mingw.cpp
===
--- cfe/trunk/test/Driver/mingw.cpp
+++ cfe/trunk/test/Driver/mingw.cpp
@@ -1,3 +1,8 @@
+// RUN: %clang -target i686-windows-gnu -c -### 
--sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_CLANG_TREE %s
+// CHECK_MINGW_CLANG_TREE: 
"{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
+// CHECK_MINGW_CLANG_TREE: 
"{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}include"
+
+
 // RUN: %clang -target i686-pc-windows-gnu -stdlib=libstdc++ -c -### 
--sysroot=%S/Inputs/mingw_mingw_org_tree/mingw %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_ORG_TREE %s
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
 // CHECK_MINGW_ORG_TREE: 
"{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
Index: cfe/trunk/lib/Driver/MinGWToolChain.cpp
===
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp
@@ -47,7 +47,7 @@
   Archs.emplace_back(getTriple().getArchName());
   Archs[0] += "-w64-mingw32";
   Archs.emplace_back("mingw32");
-  Arch = "unknown";
+  Arch = Archs[0].str();
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {


Index: cfe/trunk/test/Driver/mingw.cpp
===
--- cfe/trunk/test/Driver/mingw.cpp
+++ cfe/trunk/test/Driver/mingw.cpp
@@ -1,3 +1,8 @@
+// RUN: %clang -target i686-windows-gnu -c -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_CLANG_TREE %s
+// CHECK_MINGW_CLANG_TREE: "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
+// CHECK_MINGW_CLANG_TREE: "{{.*}}/Inputs/mingw_clang_tree/mingw32{{/|}}include"
+
+
 // RUN: %clang -target i686-pc-windows-gnu -stdlib=libstdc++ -c -### --sysroot=%S/Inputs/mingw_mingw_org_tree/mingw %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_ORG_TREE %s
 // CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++"
 // CHECK_MINGW_ORG_TREE: "{{.*}}/Inputs/mingw_mingw_org_tree/mingw{{/|}}lib{{/|}}gcc{{/|}}mingw32{{/|}}4.8.1{{/|}}include{{/|}}c++{{/|}}mingw32"
Index: cfe/trunk/lib/Driver/MinGWToolChain.cpp
===
--- cfe/trunk/lib/Driver/MinGWToolChain.cpp
+++ cfe/trunk/lib/Driver/MinGWToolChain.cpp
@@ -47,7 +47,7 @@
   Archs.emplace_back(getTriple().getArchName());
   Archs[0] += "-w64-mingw32";
   Archs.emplace_back("mingw32");
-  Arch = "unknown";
+  Arch = Archs[0].str();
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11946: Create clang-tidy module modernize. Add pass-by-value check.

2015-08-13 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

I patched this in and the tests fail for me:

  clang/tools/extra/test/clang-tidy/modernize-pass-by-value.cpp:4:17: error: 
expected string not found in input
  // CHECK-FIXES: #include 

As discussed offline, please either fix the IncludeInserter or add a fake 
include to work around the problem.


http://reviews.llvm.org/D11946



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


Need the Documentation for the LLVM pass and TypeCheck.cpp

2015-08-13 Thread Nikhil Reddy Kothapally via cfe-commits
//=== TypeChecks.cpp - Insert runtime type checks 
-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed 
under
// the University of Illinois Open Source License. See LICENSE.TXT for 
details.
//
//===--===//
//
// This pass inserts checks to enforce type safety during runtime.


http://llvm.org/doxygen/annotated.html

since the documentation i think it should be for LLVM safecode 3.7 i dont 
know whether it has updated  


am not able to find the clear doc for this since am trying to solve the 
error which i have got 

llvm[4]: Compiling PoolAllocate.cpp for Release+Asserts build
/home/NIKHILREDDY/WORK/LLVM_SRC/projects/poolalloc/lib/PoolAllocate/PoolAllocate.cpp:
 
In member function ‘virtual bool 
llvm::PoolAllocate::runOnModule(llvm::Module&)’:
/home/NIKHILREDDY/WORK/LLVM_SRC/projects/poolalloc/lib/PoolAllocate/PoolAllocate.cpp:403:16:
 
error: ‘class llvm::Constant’ has no member named 
‘replaceUsesOfWithOnConstant’
 C->replaceUsesOfWithOnConstant(F, CEnew, 
ReplaceWorklist[index]);
^
llvm[4]: Compiling PoolOptimize.cpp for Release+Asserts build
llvm[4]: Compiling RunTimeAssociate.cpp for Release+Asserts build
/usr/bin/rm: cannot remove 
‘/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib/PoolAllocate/Release+Asserts/PoolAllocate.d.tmp’:
 
No such file or directory
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:1521: recipe for target 
'/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib/PoolAllocate/Release+Asserts/PoolAllocate.o'
 
failed
make[4]: *** 
[/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib/PoolAllocate/Release+Asserts/PoolAllocate.o]
 
Error 1
make[4]: *** Waiting for unfinished jobs
make[4]: Leaving directory 
'/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib/PoolAllocate'
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:880: recipe for target 'all' 
failed
make[3]: *** [all] Error 1
make[3]: Leaving directory 
'/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib'
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:880: recipe for target 'all' 
failed
make[2]: *** [all] Error 1
make[2]: Leaving directory 
'/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc'
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:880: recipe for target 'all' 
failed
make[1]: *** [all] Error 1
make[1]: Leaving directory '/home/NIKHILREDDY/WORK/LLVM_OBJ/projects'
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:965: recipe for target 'all' 
failed
make: *** [all] Error 1
NIKHILREDDY@NikhilReddyK ~/WORK/LLVM_OBJ




-- 
You received this message because you are subscribed to the Google Groups "LLVM 
= Clang+SAFECode+Softbound+CETS (New Compiler for Windows OS)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to llvm-memorysafetycompiler+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/llvm-memorysafetycompiler.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/llvm-memorysafetycompiler/ff4d4780-5c0f-4adc-80bc-7d257e2c70c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Regarding the Error can you please give me the detailed description to solve this

2015-08-13 Thread Nikhil Reddy Kothapally via cfe-commits
Hello ,
   i have tried to solve but after removing the lib/PoolAllocate
code doesn't compile with LLVM mainline, and you don't need it for
SAFECode.  You can remove PoolAllocate from the list of directories to
compile in poolalloc/lib/Makefile. also am not able to compile this in
Windows if possible can you please give me reply in Google group
https://groups.google.com/forum/#!forum/llvm-memorysafetycompiler



  //=== TypeChecks.cpp - Insert runtime type checks
-===//
//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed
under
// the University of Illinois Open Source License. See LICENSE.TXT for
details.
//
//===--===//
//
// This pass inserts checks to enforce type safety during runtime.


the Class of this file is Cast constant so i need the child class of the
file where i am not able to solve please help out for this.

http://llvm.org/doxygen/annotated.html

since the documentation i think it should be for LLVM safecode 3.7 i dont
know whether it has updated


am not able to find the clear doc for this since am trying to solve the
error which i have got

llvm[4]: Compiling PoolAllocate.cpp for Release+Asserts build
/home/NIKHILREDDY/WORK/LLVM_SRC/projects/poolalloc/lib/PoolAllocate/PoolAllocate.cpp:
In member function ‘virtual bool
llvm::PoolAllocate::runOnModule(llvm::Module&)’:
/home/NIKHILREDDY/WORK/LLVM_SRC/projects/poolalloc/lib/PoolAllocate/PoolAllocate.cpp:403:16:
error: ‘class llvm::Constant’ has no member named
‘replaceUsesOfWithOnConstant’
 C->replaceUsesOfWithOnConstant(F, CEnew,
ReplaceWorklist[index]);
^
llvm[4]: Compiling PoolOptimize.cpp for Release+Asserts build
llvm[4]: Compiling RunTimeAssociate.cpp for Release+Asserts build
/usr/bin/rm: cannot remove
‘/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib/PoolAllocate/Release+Asserts/PoolAllocate.d.tmp’:
No such file or directory
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:1521: recipe for target
'/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib/PoolAllocate/Release+Asserts/PoolAllocate.o'
failed
make[4]: ***
[/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib/PoolAllocate/Release+Asserts/PoolAllocate.o]
Error 1
make[4]: *** Waiting for unfinished jobs
make[4]: Leaving directory
'/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib/PoolAllocate'
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:880: recipe for target 'all'
failed
make[3]: *** [all] Error 1
make[3]: Leaving directory
'/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc/lib'
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:880: recipe for target 'all'
failed
make[2]: *** [all] Error 1
make[2]: Leaving directory
'/home/NIKHILREDDY/WORK/LLVM_OBJ/projects/poolalloc'
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:880: recipe for target 'all'
failed
make[1]: *** [all] Error 1
make[1]: Leaving directory '/home/NIKHILREDDY/WORK/LLVM_OBJ/projects'
/home/NIKHILREDDY/WORK/LLVM_SRC/Makefile.rules:965: recipe for target 'all'
failed
make: *** [all] Error 1
NIKHILREDDY@NikhilReddyK ~/WORK/LLVM_OBJ

Thank You,

Kind Regards,

Nikhil Reddy Kothapally

Master Student

Technische Universität Chemnitz,(Germany)

Automotive Software Engineering.

-- 
You received this message because you are subscribed to the Google Groups "LLVM 
= Clang+SAFECode+Softbound+CETS (New Compiler for Windows OS)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to llvm-memorysafetycompiler+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/llvm-memorysafetycompiler.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/llvm-memorysafetycompiler/CA%2B%3DLHJb-HdTMfTc7voJEUmnXwFzP_5_H7VA%3Dnnk6-tJ4_xmKpA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11908: Clang support for -fthinlto.

2015-08-13 Thread David Li via cfe-commits
davidxl added a subscriber: davidxl.


Comment at: include/clang/Driver/Options.td:685
@@ -684,1 +684,3 @@
 def fno_lto : Flag<["-"], "fno-lto">, Group;
+def fthinlto : Flag<["-"], "fthinlto">, Flags<[CC1Option]>, Group;
+def fno_thinlto : Flag<["-"], "fno-thinlto">, Group;

spell it like "fthin-lto" seems better than one word "fthinlto"


Comment at: lib/CodeGen/BackendUtil.cpp:621
@@ -620,2 +620,3 @@
 getPerModulePasses()->add(
-createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
+createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+CodeGenOpts.EmitThinLTOIndex));

The change to this function is missing in the patch.


http://reviews.llvm.org/D11908



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


r244912 - [Modules] Add Darwin-specific compatibility module map parsing hacks

2015-08-13 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Aug 13 12:13:33 2015
New Revision: 244912

URL: http://llvm.org/viewvc/llvm-project?rev=244912&view=rev
Log:
[Modules] Add Darwin-specific compatibility module map parsing hacks

This preserves backwards compatibility for two hacks in the Darwin
system module map files:

1. The use of 'requires excluded' to make headers non-modular, which
should really be mapped to 'textual' now that we have this feature.

2. Silently removes a bogus cplusplus requirement from IOKit.avc.

Once we start diagnosing missing requirements and headers on
auto-imports these would have broken compatibility with existing Darwin
SDKs.

Added:
cfe/trunk/test/Modules/Inputs/System/usr/include/assert.h
cfe/trunk/test/Modules/Inputs/System/usr/include/tcl-private/
cfe/trunk/test/Modules/Inputs/System/usr/include/tcl-private/header.h
cfe/trunk/test/Modules/darwin_specific_modulemap_hacks.m
Modified:
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/Inputs/System/usr/include/module.map

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=244912&r1=244911&r2=244912&view=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Thu Aug 13 12:13:33 2015
@@ -356,6 +356,12 @@ public:
   /// its top-level module.
   std::string getFullModuleName() const;
 
+  /// \brief Whether the full name of this module is equal to joining
+  /// \p nameParts with "."s.
+  ///
+  /// This is more efficient than getFullModuleName().
+  bool fullModuleNameIs(ArrayRef nameParts) const;
+
   /// \brief Retrieve the top-level module for this (sub)module, which may
   /// be this module.
   Module *getTopLevelModule() {

Modified: cfe/trunk/lib/Basic/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=244912&r1=244911&r2=244912&view=diff
==
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Thu Aug 13 12:13:33 2015
@@ -139,6 +139,15 @@ std::string Module::getFullModuleName()
   return Result;
 }
 
+bool Module::fullModuleNameIs(ArrayRef nameParts) const {
+  for (const Module *M = this; M; M = M->Parent) {
+if (nameParts.empty() || M->Name != nameParts.back())
+  return false;
+nameParts = nameParts.drop_back();
+  }
+  return nameParts.empty();
+}
+
 Module::DirectoryName Module::getUmbrellaDir() const {
   if (Header U = getUmbrellaHeader())
 return {"", U.Entry->getDir()};

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=244912&r1=244911&r2=244912&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Thu Aug 13 12:13:33 2015
@@ -1015,7 +1015,17 @@ namespace clang {
 
 /// \brief The active module.
 Module *ActiveModule;
-
+
+/// \brief Whether a module uses the 'requires excluded' hack to mark its
+/// contents as 'textual'.
+///
+/// On older Darwin SDK versions, 'requires excluded' is used to mark the
+/// contents of the Darwin.C.excluded (assert.h) and Tcl.Private modules as
+/// non-modular headers.  For backwards compatibility, we continue to
+/// support this idiom for just these modules, and map the headers to
+/// 'textual' to match the original intent.
+llvm::SmallPtrSet UsesRequiresExcludedHack;
+
 /// \brief Consume the current token and return its location.
 SourceLocation consumeToken();
 
@@ -1570,6 +1580,38 @@ void ModuleMapParser::parseExternModuleD
 : File->getDir(), ExternLoc);
 }
 
+/// Whether to add the requirement \p Feature to the module \p M.
+///
+/// This preserves backwards compatibility for two hacks in the Darwin system
+/// module map files:
+///
+/// 1. The use of 'requires excluded' to make headers non-modular, which
+///should really be mapped to 'textual' now that we have this feature.  We
+///drop the 'excluded' requirement, and set \p IsRequiresExcludedHack to
+///true.  Later, this bit will be used to map all the headers inside this
+///module to 'textual'.
+///
+///This affects Darwin.C.excluded (for assert.h) and Tcl.Private.
+///
+/// 2. Removes a bogus cplusplus requirement from IOKit.avc.  This requirement
+///was never correct and causes issues now that we check it, so drop it.
+static bool shouldAddRequirement(Module *M, StringRef Feature,
+ bool &IsRequiresExcludedHack) {
+  static const StringRef DarwinCExcluded[] = {"Darwin", "C", "excluded"};
+  static const StringRef TclPrivate[] = {"Tcl", "Private"};
+  s

Re: [PATCH] D11403: [Modules] Add Darwin-specific compatibility module map parsing hacks

2015-08-13 Thread Ben Langmuir via cfe-commits
benlangmuir closed this revision.
benlangmuir added a comment.

Any regression to code completion was below the noise level in my testing.

r244912



Comment at: include/clang/Basic/Module.h:363
@@ +362,3 @@
+  /// This is more efficient than getFullModuleName().
+  bool fullModuleNameEqual(ArrayRef nameParts) const;
+

rsmith wrote:
> `fullModuleNameEquals` (extra 's' at the end) or `fullModuleNameIs` maybe?
I like fullModuleNameIs.


Repository:
  rL LLVM

http://reviews.llvm.org/D11403



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


Re: [PATCH] D11908: Clang support for -fthinlto.

2015-08-13 Thread Teresa Johnson via cfe-commits
tejohnson added inline comments.


Comment at: include/clang/Driver/Options.td:685
@@ -684,1 +684,3 @@
 def fno_lto : Flag<["-"], "fno-lto">, Group;
+def fthinlto : Flag<["-"], "fthinlto">, Flags<[CC1Option]>, Group;
+def fno_thinlto : Flag<["-"], "fno-thinlto">, Group;

davidxl wrote:
> spell it like "fthin-lto" seems better than one word "fthinlto"
I considered that too, but wanted to distinguish from regular LTO. I could go 
either way.


Comment at: lib/CodeGen/BackendUtil.cpp:621
@@ -620,2 +620,3 @@
 getPerModulePasses()->add(
-createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
+createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
+CodeGenOpts.EmitThinLTOIndex));

davidxl wrote:
> The change to this function is missing in the patch.
Right, that is in LLVM and needs to be in a different patch (goes into a 
different repository). As mentioned in the patch summary this is dependent on 
LLVM patch http://reviews.llvm.org/D11907.


http://reviews.llvm.org/D11908



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


r244917 - Attempt to fix build after r244912

2015-08-13 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Thu Aug 13 12:30:07 2015
New Revision: 244917

URL: http://llvm.org/viewvc/llvm-project?rev=244917&view=rev
Log:
Attempt to fix build after r244912

Some compilers were less happy about converting a lambda to a comparator
function for array_pod_sort.

Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=244917&r1=244916&r2=244917&view=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Thu Aug 13 12:30:07 2015
@@ -1855,6 +1855,11 @@ void ModuleMapParser::parseHeaderDecl(MM
   }
 }
 
+static int compareModuleHeaders(const Module::Header *A,
+const Module::Header *B) {
+  return A->NameAsWritten.compare(B->NameAsWritten);
+}
+
 /// \brief Parse an umbrella directory declaration.
 ///
 ///   umbrella-dir-declaration:
@@ -1914,10 +1919,8 @@ void ModuleMapParser::parseUmbrellaDirDe
 }
 
 // Sort header paths so that the pcm doesn't depend on iteration order.
-llvm::array_pod_sort(Headers.begin(), Headers.end(),
- [](const Module::Header *A, const Module::Header *B) {
-   return A->NameAsWritten.compare(B->NameAsWritten);
- });
+llvm::array_pod_sort(Headers.begin(), Headers.end(), compareModuleHeaders);
+
 for (auto &Header : Headers)
   Map.addHeader(ActiveModule, std::move(Header), ModuleMap::TextualHeader);
 return;


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


Re: [PATCH] D11944: Nativize filename in FileManager::getFile().

2015-08-13 Thread Richard Smith via cfe-commits
rsmith added a comment.

I would think most Windows users would be surprised if we showed them paths 
with /s instead of \s, but I'm fine with us using / internally if it doesn't 
leak out to the user.

klimek: if we want to nativize, I think the right thing to do is to remove the 
wrong "normalization" of non-Windows paths from `llvm::sys::path::native`, and 
add a more efficient overload to `llvm::sys::path::native`, such as `StringRef 
native(StringRef Input, SmallVectorImpl &Buffer)`.


http://reviews.llvm.org/D11944



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


[PATCH] D12017: Fix IncludeInserter/IncludeSorter bug.

2015-08-13 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: alexfh.
angelgarcia added subscribers: cfe-commits, klimek.
angelgarcia changed the visibility of this Differential Revision from "Public 
(No Login Required)" to "All Users".

If there weren't any includes in the file, or all of them had 'IncludeKind' 
greater than the desired one, then 'CreateIncludeInsertion' didn't work.

http://reviews.llvm.org/D12017

Files:
  clang-tidy/IncludeInserter.cpp
  clang-tidy/IncludeSorter.cpp
  clang-tidy/IncludeSorter.h

Index: clang-tidy/IncludeSorter.h
===
--- clang-tidy/IncludeSorter.h
+++ clang-tidy/IncludeSorter.h
@@ -21,27 +21,23 @@
 // the necessary commands to sort the inclusions according to the precedence
 // enocded in IncludeKinds.
 class IncludeSorter {
- public:
+public:
   // Supported include styles.
-  enum IncludeStyle {
-IS_LLVM = 0,
-IS_Google = 1
-  };
+  enum IncludeStyle { IS_LLVM = 0, IS_Google = 1 };
 
   // The classifications of inclusions, in the order they should be sorted.
   enum IncludeKinds {
-IK_MainTUInclude = 0, // e.g. #include "foo.h" when editing foo.cc
-IK_CSystemInclude = 1,// e.g. #include 
-IK_CXXSystemInclude = 2,  // e.g. #include 
-IK_NonSystemInclude = 3,  // e.g. #include "bar.h"
-IK_InvalidInclude = 4 // total number of valid IncludeKinds
+IK_MainTUInclude = 0,// e.g. #include "foo.h" when editing foo.cc
+IK_CSystemInclude = 1,   // e.g. #include 
+IK_CXXSystemInclude = 2, // e.g. #include 
+IK_NonSystemInclude = 3, // e.g. #include "bar.h"
+IK_InvalidInclude = 4// total number of valid IncludeKinds
   };
 
   // IncludeSorter constructor; takes the FileID and name of the file to be
   // processed by the sorter.
-  IncludeSorter(const SourceManager* SourceMgr,
-const LangOptions* LangOpts, const FileID FileID,
-StringRef FileName, IncludeStyle Style);
+  IncludeSorter(const SourceManager *SourceMgr, const LangOptions *LangOpts,
+const FileID FileID, StringRef FileName, IncludeStyle Style);
 
   // Returns the SourceManager-specific file ID for the file being handled by
   // the sorter.
@@ -58,18 +54,17 @@
 
   // Creates a quoted inclusion directive in the right sort order. Returns None
   // on error or if header inclusion directive for header already exists.
-  Optional CreateIncludeInsertion(StringRef FileName,
- bool IsAngled);
+  Optional CreateIncludeInsertion(StringRef FileName, bool IsAngled);
 
- private:
+private:
   typedef SmallVector SourceRangeVector;
 
   // Creates a fix-it for the given replacements.
   // Takes the the source location that will be replaced, and the new text.
-  FixItHint CreateFixIt(SourceRange EditRange, const std::string& NewText);
+  FixItHint CreateFixIt(SourceRange EditRange, const std::string &NewText);
 
-  const SourceManager* SourceMgr;
-  const LangOptions* LangOpts;
+  const SourceManager *SourceMgr;
+  const LangOptions *LangOpts;
   const IncludeStyle Style;
   FileID CurrentFileID;
   // The file name stripped of common suffixes.
@@ -82,6 +77,6 @@
   SmallVector IncludeBucket[IK_InvalidInclude];
 };
 
-}  // namespace tidy
-}  // namespace clang
+} // namespace tidy
+} // namespace clang
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H
Index: clang-tidy/IncludeSorter.cpp
===
--- clang-tidy/IncludeSorter.cpp
+++ clang-tidy/IncludeSorter.cpp
@@ -111,14 +111,18 @@
 
 Optional IncludeSorter::CreateIncludeInsertion(StringRef FileName,
   bool IsAngled) {
-  if (SourceLocations.empty()) {
-return None;
-  }
   std::string IncludeStmt =
   IsAngled ? llvm::Twine("#include <" + FileName + ">\n").str()
: llvm::Twine("#include \"" + FileName + "\"\n").str();
+  if (SourceLocations.empty()) {
+// If there are no includes in this file, add it in the first line.
+return FixItHint::CreateInsertion(
+SourceMgr->getLocForStartOfFile(CurrentFileID), IncludeStmt);
+  }
+
   auto IncludeKind =
   DetermineIncludeKind(CanonicalFile, FileName, IsAngled, Style);
+
   if (!IncludeBucket[IncludeKind].empty()) {
 for (const std::string &IncludeEntry : IncludeBucket[IncludeKind]) {
   if (FileName < IncludeEntry) {
@@ -136,7 +140,7 @@
   IncludeStmt);
   }
   IncludeKinds NonEmptyKind = IK_InvalidInclude;
-  for (int i = IncludeKind - 1; i >= 0; --i) {
+  for (int i = IK_InvalidInclude - 1; i >= 0; --i) {
 if (!IncludeBucket[i].empty()) {
   NonEmptyKind = static_cast(i);
   break;
@@ -147,9 +151,8 @@
   }
   const std::string &LastInclude = IncludeBucket[NonEmptyKind].back();
   SourceRange LastIncludeLocation = IncludeLocations[LastInclude].back();
-  IncludeStmt.append("\n");
-  retur

Re: r244867 - Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.

2015-08-13 Thread Ivan Krasin via cfe-commits
Thank you, Yaron.

Sorry for breaking the build, it obviously passed locally and I didn't
think about all the variety of the supported configs. :(

Does LLVM have try bots, so that I can run the tests with my patch before
committing it?

krasin

On Thu, Aug 13, 2015 at 3:40 AM, Renato Golin 
wrote:

> On 13 August 2015 at 07:15, Yaron Keren via cfe-commits
>  wrote:
> > CHECK-EIGHT is failing bots, see
> >
> >
> http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24306/steps/check-all/logs/FAIL%3A%20Clang%3A%3Adependency-gen.c
>
>
> That check only works if compiler-rt is built in, and supports the
> target. I wouldn't put that in a Clang test.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10365: Add cmd to compilation database file format

2015-08-13 Thread Daniel Dilts via cfe-commits
diltsman updated this revision to Diff 32082.
diltsman marked an inline comment as done.
diltsman added a comment.

Arguments and Command can now be in the same compilation database for the same 
file.  Arguments are preferred when both are present.


http://reviews.llvm.org/D10365

Files:
  ../llvm/tools/clang/include/clang/Tooling/JSONCompilationDatabase.h
  ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp
  ../llvm/tools/clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: ../llvm/tools/clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- ../llvm/tools/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ ../llvm/tools/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -36,8 +36,13 @@
   expectFailure("[{[]:\"\"}]", "Incorrectly typed entry");
   expectFailure("[{}]", "Empty entry");
   expectFailure("[{\"directory\":\"\",\"command\":\"\"}]", "Missing file");
-  expectFailure("[{\"directory\":\"\",\"file\":\"\"}]", "Missing command");
+  expectFailure("[{\"directory\":\"\",\"file\":\"\"}]", "Missing command or arguments");
   expectFailure("[{\"command\":\"\",\"file\":\"\"}]", "Missing directory");
+  expectFailure("[{\"directory\":\"\",\"arguments\":[]}]", "Missing file");
+  expectFailure("[{\"arguments\":\"\",\"file\":\"\"}]", "Missing directory");
+  expectFailure("[{\"command\":\"\",\"arguments\":[],\"file\":\"\"}]", "Command and arguments");
+  expectFailure("[{\"directory\":\"\",\"arguments\":\"\",\"file\":\"\"}]", "Arguments not array");
+  expectFailure("[{\"directory\":\"\",\"command\":[],\"file\":\"\"}]", "Command not string");
 }
 
 static std::vector getAllFiles(StringRef JSONDatabase,
Index: ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -221,9 +221,8 @@
 SmallString<8> DirectoryStorage;
 SmallString<1024> CommandStorage;
 Commands.emplace_back(
-// FIXME: Escape correctly:
-CommandsRef[I].first->getValue(DirectoryStorage),
-unescapeCommandLine(CommandsRef[I].second->getValue(CommandStorage)));
+  CommandsRef[I].first->getValue(DirectoryStorage),
+  CommandsRef[I].second);
   }
 }
 
@@ -243,43 +242,55 @@
 ErrorMessage = "Expected array.";
 return false;
   }
-  for (llvm::yaml::SequenceNode::iterator AI = Array->begin(),
-  AE = Array->end();
-   AI != AE; ++AI) {
-llvm::yaml::MappingNode *Object = dyn_cast(&*AI);
+  for (auto& NextObject : *Array) {
+llvm::yaml::MappingNode *Object = dyn_cast(&NextObject);
 if (!Object) {
   ErrorMessage = "Expected object.";
   return false;
 }
 llvm::yaml::ScalarNode *Directory = nullptr;
-llvm::yaml::ScalarNode *Command = nullptr;
+std::vector Arguments;
+std::vector Command;
 llvm::yaml::ScalarNode *File = nullptr;
-for (llvm::yaml::MappingNode::iterator KVI = Object->begin(),
-   KVE = Object->end();
- KVI != KVE; ++KVI) {
-  llvm::yaml::Node *Value = (*KVI).getValue();
+for (auto& NextKeyValue : *Object) {
+  llvm::yaml::ScalarNode *KeyString =
+  dyn_cast(NextKeyValue.getKey());
+  if (!KeyString) {
+ErrorMessage = "Expected strings as key.";
+return false;
+  }
+  SmallString<8> KeyStorage;
+  StringRef KeyValue = KeyString->getValue(KeyStorage);
+  llvm::yaml::Node *Value = NextKeyValue.getValue();
   if (!Value) {
 ErrorMessage = "Expected value.";
 return false;
   }
   llvm::yaml::ScalarNode *ValueString =
   dyn_cast(Value);
-  if (!ValueString) {
-ErrorMessage = "Expected string as value.";
+  llvm::yaml::SequenceNode *SequenceString =
+  dyn_cast(Value);
+  if (KeyValue == "arguments" && !SequenceString) {
+ErrorMessage = "Expected sequence as value.";
 return false;
-  }
-  llvm::yaml::ScalarNode *KeyString =
-  dyn_cast((*KVI).getKey());
-  if (!KeyString) {
-ErrorMessage = "Expected strings as key.";
+  } else if (KeyValue != "arguments" && !ValueString) {
+ErrorMessage = "Expected string as value.";
 return false;
   }
-  SmallString<8> KeyStorage;
-  if (KeyString->getValue(KeyStorage) == "directory") {
+  if (KeyValue == "directory") {
 Directory = ValueString;
-  } else if (KeyString->getValue(KeyStorage) == "command") {
-Command = ValueString;
-  } else if (KeyString->getValue(KeyStorage) == "file") {
+  } else if (KeyValue == "arguments") {
+for (auto& NextArgument : *SequenceString) {
+  SmallString<128> CommandStorage;
+  auto ValueString = dyn_cast(&NextArgument);
+
+  Arguments.push_

r244923 - [modules] Change the way we deal with .d output for explicitly-specified module

2015-08-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 13 12:57:10 2015
New Revision: 244923

URL: http://llvm.org/viewvc/llvm-project?rev=244923&view=rev
Log:
[modules] Change the way we deal with .d output for explicitly-specified module
files: include the .pcm file itself in the .d output, rather than including its
own input files. Other forms of module file continue to be transparent for .d
output.

Arguably, the input files for the .pcm file are still inputs to the
compilation, but that's unnecessary for make-like build systems (where the
mtime of the .pcm file is sufficient) and harmful for smarter build systems
that know about module files and want to track only the local dependencies.

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Frontend/DependencyFile.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/dependency-gen.modulemap

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=244923&r1=244922&r2=244923&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Aug 13 12:57:10 2015
@@ -179,7 +179,8 @@ public:
unsigned Value) {}
 
   /// This is called for each AST file loaded.
-  virtual void visitModuleFile(StringRef Filename) {}
+  virtual void visitModuleFile(StringRef Filename,
+   serialization::ModuleKind Kind) {}
 
   /// \brief Returns true if this \c ASTReaderListener wants to receive the
   /// input files of the AST file via \c visitInputFile, false otherwise.
@@ -194,7 +195,7 @@ public:
   ///
   /// \returns true to continue receiving the next input file, false to stop.
   virtual bool visitInputFile(StringRef Filename, bool isSystem,
-  bool isOverridden) {
+  bool isOverridden, bool isExplicitModule) {
 return true;
   }
 
@@ -242,9 +243,10 @@ public:
   void ReadCounter(const serialization::ModuleFile &M, unsigned Value) 
override;
   bool needsInputFileVisitation() override;
   bool needsSystemInputFileVisitation() override;
-  void visitModuleFile(StringRef Filename) override;
+  void visitModuleFile(StringRef Filename,
+   serialization::ModuleKind Kind) override;
   bool visitInputFile(StringRef Filename, bool isSystem,
-  bool isOverridden) override;
+  bool isOverridden, bool isExplicitModule) override;
 };
 
 /// \brief ASTReaderListener implementation to validate the information of

Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244923&r1=244922&r2=244923&view=diff
==
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Thu Aug 13 12:57:10 2015
@@ -104,14 +104,15 @@ struct DepCollectorASTListener : public
   bool needsSystemInputFileVisitation() override {
 return DepCollector.needSystemDependencies();
   }
-  void visitModuleFile(StringRef Filename) override {
+  void visitModuleFile(StringRef Filename,
+   serialization::ModuleKind Kind) override {
 DepCollector.maybeAddDependency(Filename, /*FromModule*/true,
/*IsSystem*/false, /*IsModuleFile*/true,
/*IsMissing*/false);
   }
   bool visitInputFile(StringRef Filename, bool IsSystem,
-  bool IsOverridden) override {
-if (IsOverridden)
+  bool IsOverridden, bool IsExplicitModule) override {
+if (IsOverridden || IsExplicitModule)
   return true;
 
 DepCollector.maybeAddDependency(Filename, /*FromModule*/true, IsSystem,
@@ -226,9 +227,10 @@ public:
   bool needsSystemInputFileVisitation() override {
 return Parent.includeSystemHeaders();
   }
-  void visitModuleFile(StringRef Filename) override;
+  void visitModuleFile(StringRef Filename,
+   serialization::ModuleKind Kind) override;
   bool visitInputFile(StringRef Filename, bool isSystem,
-  bool isOverridden) override;
+  bool isOverridden, bool isExplicitModule) override;
 };
 }
 
@@ -472,16 +474,18 @@ void DFGImpl::OutputDependencyFile() {
 }
 
 bool DFGASTReaderListener::visitInputFile(llvm::StringRef Filename,
-  bool IsSystem, bool IsOverridden) {
+  bool IsSystem, bool IsOverridden,
+  bool IsExplicitModule) {
   assert(!IsSystem || needsSystemInputFileVisitation());
-  if (IsOverridden)
+  if (IsOve

r244922 - Turn off __has_feature(cxx_rtti) when -fno-rtti-data is present

2015-08-13 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Aug 13 12:56:49 2015
New Revision: 244922

URL: http://llvm.org/viewvc/llvm-project?rev=244922&view=rev
Log:
Turn off __has_feature(cxx_rtti) when -fno-rtti-data is present

-fno-rtti-data makes it so that vtables emitted in the current TU lack
RTTI data. This means that dynamic_cast usually fails at runtime. Users
of the existing cxx_rtti feature expect all of RTTI to work, not just
some of it.

Chromium bug for context: http://crbug.com/518191

Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Lexer/has_feature_rtti.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=244922&r1=244921&r2=244922&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Thu Aug 13 12:56:49 2015
@@ -1076,7 +1076,7 @@ static bool HasFeature(const Preprocesso
   .Case("blocks", LangOpts.Blocks)
   .Case("c_thread_safety_attributes", true)
   .Case("cxx_exceptions", LangOpts.CXXExceptions)
-  .Case("cxx_rtti", LangOpts.RTTI)
+  .Case("cxx_rtti", LangOpts.RTTI && LangOpts.RTTIData)
   .Case("enumerator_attributes", true)
   .Case("nullability", true)
   .Case("memory_sanitizer", LangOpts.Sanitize.has(SanitizerKind::Memory))

Modified: cfe/trunk/test/Lexer/has_feature_rtti.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_rtti.cpp?rev=244922&r1=244921&r2=244922&view=diff
==
--- cfe/trunk/test/Lexer/has_feature_rtti.cpp (original)
+++ cfe/trunk/test/Lexer/has_feature_rtti.cpp Thu Aug 13 12:56:49 2015
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-RTTI %s
 // RUN: %clang_cc1 -E -fno-rtti %s -o - | FileCheck 
--check-prefix=CHECK-NO-RTTI %s
+// RUN: %clang_cc1 -E -fno-rtti-data %s -o - | FileCheck 
--check-prefix=CHECK-NO-RTTI %s
 
 #if __has_feature(cxx_rtti)
 int foo();


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


Re: r244867 - Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.

2015-08-13 Thread Yaron Keren via cfe-commits
There is great variety of OSs, compilers, configs in the bots. You can't
get the smae with try bots unless everything is duplicated which is a
waste. You test locally, commit, watch the bots here:

 http://lab.llvm.org:8011/grid

or wait for buildbot failure e-mails which arrive a bit slower.
Breaks may happen even if you test locally, so it's critical be around
after the commit to to resolve such issues.

 http://llvm.org/docs/DeveloperPolicy.html#quality



2015-08-13 20:51 GMT+03:00 Ivan Krasin :

> Thank you, Yaron.
>
> Sorry for breaking the build, it obviously passed locally and I didn't
> think about all the variety of the supported configs. :(
>
> Does LLVM have try bots, so that I can run the tests with my patch before
> committing it?
>
> krasin
>

On Thu, Aug 13, 2015 at 3:40 AM, Renato Golin 
wrote:

> On 13 August 2015 at 07:15, Yaron Keren via cfe-commits
>  wrote:
> > CHECK-EIGHT is failing bots, see
> >
> >
> http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24306/steps/check-all/logs/FAIL%3A%20Clang%3A%3Adependency-gen.c
>
>
> That check only works if compiler-rt is built in, and supports the
> target. I wouldn't put that in a Clang test.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r244926 - Try to fix the build after r244923

2015-08-13 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Aug 13 13:10:34 2015
New Revision: 244926

URL: http://llvm.org/viewvc/llvm-project?rev=244926&view=rev
Log:
Try to fix the build after r244923

Modified:
cfe/trunk/lib/Frontend/DependencyFile.cpp

Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244926&r1=244925&r2=244926&view=diff
==
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Thu Aug 13 13:10:34 2015
@@ -486,6 +486,6 @@ bool DFGASTReaderListener::visitInputFil
 
 void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename,
serialization::ModuleKind Kind) {
-  if (Parent.includeModuleFiles() || Kind == MK_ExplicitModule)
+  if (Parent.includeModuleFiles() || Kind == serialization::MK_ExplicitModule)
 Parent.AddFilename(Filename);
 }


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


r244925 - Try to fix new.cpp after r244920 to make it pass

2015-08-13 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Aug 13 13:10:32 2015
New Revision: 244925

URL: http://llvm.org/viewvc/llvm-project?rev=244925&view=rev
Log:
Try to fix new.cpp after r244920 to make it pass

Modified:
cfe/trunk/test/CodeGenCXX/new.cpp

Modified: cfe/trunk/test/CodeGenCXX/new.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/new.cpp?rev=244925&r1=244924&r2=244925&view=diff
==
--- cfe/trunk/test/CodeGenCXX/new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/new.cpp Thu Aug 13 13:10:32 2015
@@ -371,12 +371,12 @@ namespace builtins {
 // CHECK-DAG: attributes [[ATTR_NOBUILTIN]] = {{[{].*}} nobuiltin {{.*[}]}}
 // CHECK-DAG: attributes [[ATTR_NOBUILTIN_NOUNWIND]] = {{[{].*}} nobuiltin 
nounwind {{.*[}]}}
 
+// CHECK-DAG: attributes [[ATTR_BUILTIN_NEW]] = {{[{].*}} builtin {{.*[}]}}
+// CHECK-DAG: attributes [[ATTR_BUILTIN_DELETE]] = {{[{].*}} builtin {{.*[}]}}
+
 // CHECK: attributes [[ATTR_NOUNWIND]] =
 // CHECK-NOT: builtin
 // CHECK-NOT: attributes
 // CHECK: nounwind
 // CHECK-NOT: builtin
-// CHECK: attributes
-
-// CHECK-DAG: attributes [[ATTR_BUILTIN_NEW]] = {{[{].*}} builtin {{.*[}]}}
-// CHECK-DAG: attributes [[ATTR_BUILTIN_DELETE]] = {{[{].*}} builtin {{.*[}]}}
+// CHECK-NOT: attributes


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


Re: [PATCH] D11859: Generating vptr assume loads

2015-08-13 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/CodeGen/CGCXXABI.h:349-357
@@ -348,1 +348,11 @@
 
+  virtual bool
+  isVirtualOffsetNeededForVTableField(CodeGenFunction &CGF,
+  const CXXRecordDecl *NearestVBase) = 0;
+
+  virtual bool canInitializeVPtr(const CXXRecordDecl *VTableClass,
+ const CXXRecordDecl *Base,
+ const CXXRecordDecl *NearestVBase) = 0;
+
+  /// Get the address point of the vtable for the given base subobject
+  virtual llvm::Constant *

Please also add documentation comments for the other two. =)


http://reviews.llvm.org/D11859



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


r244927 - Fix wrong expected test output in r244923.

2015-08-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 13 13:11:20 2015
New Revision: 244927

URL: http://llvm.org/viewvc/llvm-project?rev=244927&view=rev
Log:
Fix wrong expected test output in r244923.

Modified:
cfe/trunk/test/Modules/dependency-gen.modulemap

Modified: cfe/trunk/test/Modules/dependency-gen.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.modulemap?rev=244927&r1=244926&r2=244927&view=diff
==
--- cfe/trunk/test/Modules/dependency-gen.modulemap (original)
+++ cfe/trunk/test/Modules/dependency-gen.modulemap Thu Aug 13 13:11:20 2015
@@ -28,9 +28,9 @@ module "test" {
 //
 // EXPLICIT: {{^}}explicit.pcm:
 // EXPLICIT-NOT: dependency-gen-
-// EXPLICIT: base.pcm
-// EXPLICIT-NOT: dependency-gen-
 // EXPLICIT: {{.*[/\\]}}dependency-gen.modulemap
 // EXPLICIT-NOT: dependency-gen-
+// EXPLICIT: base.pcm
+// EXPLICIT-NOT: dependency-gen-
 // EXPLICIT: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h
 // EXPLICIT-NOT: dependency-gen-


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


r244928 - Remove and forbid raw_svector_ostream::flush() calls.

2015-08-13 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Thu Aug 13 13:12:56 2015
New Revision: 244928

URL: http://llvm.org/viewvc/llvm-project?rev=244928&view=rev
Log:
Remove and forbid raw_svector_ostream::flush() calls.
After r244870 flush() will only compare two null pointers and return,
doing nothing but wasting run time. The call is not required any more
as the stream and its SmallString are always in sync.

Thanks to David Blaikie for reviewing.


Modified:
cfe/trunk/lib/ARCMigrate/ARCMT.cpp
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/lib/AST/ASTDiagnostic.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Mangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Index/CommentToXML.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/lib/ARCMigrate/ARCMT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ARCMT.cpp?rev=244928&r1=244927&r2=244928&view=diff
==
--- cfe/trunk/lib/ARCMigrate/ARCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ARCMT.cpp Thu Aug 13 13:12:56 2015
@@ -600,7 +600,6 @@ bool MigrationProcess::applyTransform(Tr
 SmallString<512> newText;
 llvm::raw_svector_ostream vecOS(newText);
 buf.write(vecOS);
-vecOS.flush();
 std::unique_ptr memBuf(
 llvm::MemoryBuffer::getMemBufferCopy(
 StringRef(newText.data(), newText.size()), newFname));

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=244928&r1=244927&r2=244928&view=diff
==
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Thu Aug 13 13:12:56 2015
@@ -1982,7 +1982,6 @@ void ObjCMigrateASTConsumer::HandleTrans
 SmallString<512> newText;
 llvm::raw_svector_ostream vecOS(newText);
 buf.write(vecOS);
-vecOS.flush();
 std::unique_ptr memBuf(
 llvm::MemoryBuffer::getMemBufferCopy(
 StringRef(newText.data(), newText.size()), file->getName()));
@@ -2215,7 +2214,6 @@ static std::string applyEditsToTemp(cons
   SmallString<512> NewText;
   llvm::raw_svector_ostream OS(NewText);
   Buf->write(OS);
-  OS.flush();
 
   SmallString<64> TempPath;
   int FD;

Modified: cfe/trunk/lib/AST/ASTDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDiagnostic.cpp?rev=244928&r1=244927&r2=244928&view=diff
==
--- cfe/trunk/lib/AST/ASTDiagnostic.cpp (original)
+++ cfe/trunk/lib/AST/ASTDiagnostic.cpp Thu Aug 13 13:12:56 2015
@@ -445,8 +445,6 @@ void clang::FormatASTNodeDiagnosticArgum
 
   }
 
-  OS.flush();
-
   if (NeedQuotes) {
 Output.insert(Output.begin()+OldEnd, '\'');
 Output.push_back('\'');

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=244928&r1=244927&r2=244928&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Aug 13 13:12:56 2015
@@ -498,7 +498,6 @@ std::string PredefinedExpr::ComputeName(
 else
   MC->mangleName(ND, Out);
 
-Out.flush();
 if (!Buffer.empty() && Buffer.front() == '\01')
   return Buffer.substr(1);
 return Buffer.str();
@@ -660,7 +659,6 @@ std::string PredefinedExpr::ComputeName(
 
 Out << Proto;
 
-Out.flush();
 return Name.str().str();
   }
   if (const CapturedDecl *CD = dyn_cast(CurrentDecl)) {
@@ -692,7 +690,6 @@ std::string PredefinedExpr::ComputeName(
 MD->getSelector().print(Out);
 Out <<  ']';
 
-Out.flush();
 return Name.str().str();
   }
   if (isa(CurrentDecl) && IT == PrettyFunction) {

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=244928&r1=244927&r2=244928&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Thu Aug 13 13:12:56 2015
@@ -2405,7 +2405,6 @@ void CXXNameMangler::mangleType(const Ob
   StringRef name = I->getName();
   Qua

Re: r244926 - Try to fix the build after r244923

2015-08-13 Thread Richard Smith via cfe-commits
On Thu, Aug 13, 2015 at 11:10 AM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Thu Aug 13 13:10:34 2015
> New Revision: 244926
>
> URL: http://llvm.org/viewvc/llvm-project?rev=244926&view=rev
> Log:
> Try to fix the build after r244923
>

Thanks! I thought I'd run the tests on that patch, but apparently I only
ran them on a previous version. =(


> Modified:
> cfe/trunk/lib/Frontend/DependencyFile.cpp
>
> Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244926&r1=244925&r2=244926&view=diff
>
> ==
> --- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
> +++ cfe/trunk/lib/Frontend/DependencyFile.cpp Thu Aug 13 13:10:34 2015
> @@ -486,6 +486,6 @@ bool DFGASTReaderListener::visitInputFil
>
>  void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename,
> serialization::ModuleKind
> Kind) {
> -  if (Parent.includeModuleFiles() || Kind == MK_ExplicitModule)
> +  if (Parent.includeModuleFiles() || Kind ==
> serialization::MK_ExplicitModule)
>  Parent.AddFilename(Filename);
>  }
>
>
> ___
> 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] RE: [cfe-dev] missing return statement for non-void functions in C++

2015-08-13 Thread Richard Smith via cfe-commits
On Thu, Aug 13, 2015 at 1:52 AM, Sjoerd Meijer 
wrote:

> Hi Richard,
>
> Thanks for reviewing. Agree, that was a bit confusing. More specifically,
>
> the warning message was confusing (i.e. wrong). This patch is for
> compiling .c
>
> input in C++ mode. The new flag should be ignored for C++ **input**, and
> indeed
>
> not when it is in C++ *mode* as the warning message said earlier. So I
> have
>
> changed the warning message accordingly and hope that solves it, see
> attached
>
> patch.
>

What is the distinction you're trying to draw here? This patch still
doesn't make sense to me. This flag is only meaningful when compiling as
C++. You ignore it when compiling as C but produce a warning that says it's
ignored when compiling as C++.


> Cheers.
>
>
>
> *From:* meta...@gmail.com [mailto:meta...@gmail.com] *On Behalf Of *Richard
> Smith
> *Sent:* 12 August 2015 23:06
> *To:* Sjoerd Meijer
> *Cc:* Hal Finkel; Marshall Clow; cfe-commits
>
> *Subject:* Re: [PATCH] RE: [cfe-dev] missing return statement for
> non-void functions in C++
>
>
>
> This patch seems a bit confused. You warn that the flag is ignored in C++,
> but it only has an effect in C++. You have a testcase with a .c extension
> that is built with -x c++.
>
>
>
> On Wed, Aug 12, 2015 at 5:23 AM, Sjoerd Meijer 
> wrote:
>
> [ + cfe-commits@lists.llvm.org ]
>
>
>
> Hi,
>
> The functionality is now available under a flag, see attached patch. Note
> that the flag is ignored in C++ mode, so it will help the use case of
> compiling (legacy) C code with a C++ compiler.
>
> Cheers,
>
> Sjoerd.
>
>
>
> *From:* Sjoerd Meijer [mailto:sjoerd.mei...@arm.com
> ]
> *Sent:* 03 August 2015 11:40
> *To:* 'Richard Smith'
> *Cc:* Hal Finkel; Marshall Clow; cfe-...@cs.uiuc.edu Developers; cfe
> commits
> *Subject:* RE: [PATCH] RE: [cfe-dev] missing return statement for
> non-void functions in C++
>
>
>
> Hi Richard,
>
>
>
> I agree with your conclusions and will start preparing a patch for option
> 3) under a flag that is off by default; this enables folks to build/run C
> code in C++. I actually think option 2) would be a good one too, but as it
> is already available under a flag I also don’t see how useful it is
> combining options 2) and 3) with another (or one more) flag that is off by
> default.
>
>
>
> Cheers.
>
>
>
> *From:* meta...@gmail.com [mailto:meta...@gmail.com ] *On
> Behalf Of *Richard Smith
> *Sent:* 31 July 2015 19:46
> *To:* Sjoerd Meijer
> *Cc:* Hal Finkel; Marshall Clow; cfe-...@cs.uiuc.edu Developers; cfe
> commits
> *Subject:* Re: [PATCH] RE: [cfe-dev] missing return statement for
> non-void functions in C++
>
>
>
> On Fri, Jul 31, 2015 at 7:35 AM, Sjoerd Meijer 
> wrote:
>
> Hi, I am not sure if we came to a conclusion. Please find attached a
> patch. It simply removes the two lines that insert an unreachable statement
> (which cause removal of the return statement). Please note that at -O0 the
> trap instruction is still generated. Is this something we could live with?
>
>
>
> I don't think this is an improvement:
>
>
>
> This doesn't satisfy the folks who want an 'unreachable' for better code
> size and optimization, and it doesn't satisfy the folks who want a
> guaranteed trap for security, and it doesn't satisfy the folks who want
> their broken code to limp along (because it'll still trap at -O0), and it
> is at best a minor improvement for the folks who want missing returns to be
> more easily debuggable (with -On, the code goes wrong in the caller, or
> appears to work, rather than falling into an unrelated function, and
> debugging this with -O0 was already easy).
>
>
>
> I think there are three options that are defensible here:
>
> 1) The status quo: this is UB and we treat it as such and optimize on that
> basis, but provide a trap as a convenience at -O0
>
> 2) The secure approach: this is UB but we always trap
>
> 3) Define the behavior to return 'undef' for C types: this allows
> questionable C code that has UB in C++ to keep working when built with a
> C++ compiler
>
>
>
> Note that (3) can be combined with either (1) or (2). (2) is already
> available via the 'return' sanitizer. So this really reduces to: in those
> cases where C says it's OK so long as the caller doesn't look at the
> returned value (and where the return type doesn't have a non-trivial copy
> constructor or destructor, isn't a reference, and so on), should we attempt
> to preserve the C behaviour? I would be OK with putting that behind a `-f`
> flag (perhaps `-fstrict-return` or similar) to support those folks who want
> to build C code in C++, but I would suggest having that flag be off by
> default, since that is not the usual use case for a C++ compiler.
>
>
>
> Cheers,
>
> Sjoerd.
>
>
>
> *From:* cfe-dev-boun...@cs.uiuc.edu [mailto:cfe-dev-boun...@cs.uiuc.edu] *On
> Behalf Of *Richard Smith
> *Sent:* 29 July 2015 18:07
> *To:* Hal Finkel
> *Cc:* Marshall Clow; cfe-...@cs.uiuc.edu Developers
>
>
> *Subject:* Re: [cfe-dev] missing return statement for non

r244931 - [modules] For explicit module file dependencies, only list direct dependency module files.

2015-08-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 13 13:30:25 2015
New Revision: 244931

URL: http://llvm.org/viewvc/llvm-project?rev=244931&view=rev
Log:
[modules] For explicit module file dependencies, only list direct dependency 
module files.

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/DependencyFile.cpp
cfe/trunk/test/Modules/dependency-gen.modulemap

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=244931&r1=244930&r2=244931&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Aug 13 13:30:25 2015
@@ -709,6 +709,9 @@ static void ParseDependencyOutputArgs(De
   // They won't be discovered by the regular preprocessor, so
   // we let make / ninja to know about this implicit dependency.
   Opts.ExtraDeps = Args.getAllArgValues(OPT_fsanitize_blacklist);
+  auto ModuleFiles = Args.getAllArgValues(OPT_fmodule_file);
+  Opts.ExtraDeps.insert(Opts.ExtraDeps.end(), ModuleFiles.begin(),
+ModuleFiles.end());
 }
 
 bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,

Modified: cfe/trunk/lib/Frontend/DependencyFile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DependencyFile.cpp?rev=244931&r1=244930&r2=244931&view=diff
==
--- cfe/trunk/lib/Frontend/DependencyFile.cpp (original)
+++ cfe/trunk/lib/Frontend/DependencyFile.cpp Thu Aug 13 13:30:25 2015
@@ -486,6 +486,6 @@ bool DFGASTReaderListener::visitInputFil
 
 void DFGASTReaderListener::visitModuleFile(llvm::StringRef Filename,
serialization::ModuleKind Kind) {
-  if (Parent.includeModuleFiles() || Kind == serialization::MK_ExplicitModule)
+  if (Parent.includeModuleFiles())
 Parent.AddFilename(Filename);
 }

Modified: cfe/trunk/test/Modules/dependency-gen.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen.modulemap?rev=244931&r1=244930&r2=244931&view=diff
==
--- cfe/trunk/test/Modules/dependency-gen.modulemap (original)
+++ cfe/trunk/test/Modules/dependency-gen.modulemap Thu Aug 13 13:30:25 2015
@@ -5,6 +5,8 @@
 //
 // RUN: %clang_cc1 -I. -x c++ -fmodule-name=test-base -fmodules -emit-module 
-fno-validate-pch -fmodules-strict-decluse Inputs/dependency-gen-base.modulemap 
-o %t/base.pcm -fmodule-map-file-home-is-cwd 
-fmodule-map-file=%S/Inputs/dependency-gen-base.modulemap
 // RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module 
-fno-validate-pch -fmodules-strict-decluse -fmodule-file=%t/base.pcm %s 
-dependency-file - -MT explicit.pcm -o %t/explicit.pcm -fmodules-cache-path=%t 
-fmodule-map-file-home-is-cwd | FileCheck %s --check-prefix=EXPLICIT
+//
+// RUN: %clang_cc1 -I. -x c++ -fmodules -include Inputs/dependency-gen.h -x 
c++ /dev/null -fmodule-file=%t/explicit.pcm -MT main.o -fsyntax-only 
-dependency-file - | FileCheck %s --check-prefix=EXPLICIT-USE
 module "test" {
   export *
   header "Inputs/dependency-gen.h"
@@ -34,3 +36,8 @@ module "test" {
 // EXPLICIT-NOT: dependency-gen-
 // EXPLICIT: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h
 // EXPLICIT-NOT: dependency-gen-
+
+// EXPLICIT-USE: main.o:
+// EXPLICIT-USE-NOT: base.pcm
+// EXPLICIT-USE: explicit.pcm
+// EXPLICIT-USE-NOT: base.pcm


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


Re: [PATCH] D10365: Add cmd to compilation database file format

2015-08-13 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a reviewer: klimek.
klimek added a comment.
This revision is now accepted and ready to land.

LG with a happy path test.



Comment at: ../llvm/tools/clang/unittests/Tooling/CompilationDatabaseTest.cpp:45
@@ -41,1 +44,3 @@
+  expectFailure("[{\"directory\":\"\",\"arguments\":\"\",\"file\":\"\"}]", 
"Arguments not array");
+  expectFailure("[{\"directory\":\"\",\"command\":[],\"file\":\"\"}]", 
"Command not string");
 }

Please add a happy path test, too.


http://reviews.llvm.org/D10365



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


r244933 - Fix previous commit: poison only class members, simpler tests

2015-08-13 Thread Naomi Musgrave via cfe-commits
Author: nmusgrave
Date: Thu Aug 13 13:35:11 2015
New Revision: 244933

URL: http://llvm.org/viewvc/llvm-project?rev=244933&view=rev
Log:
Fix previous commit: poison only class members, simpler tests

Summary: Poisoning applied to only class members, and before dtors for base 
class invoked

Implement poisoning of only class members in dtor, as opposed to also
poisoning fields inherited from base classes. Members are poisoned
only once, by the last dtor for a class. Skip poisoning if class has
no fields.
Verify emitted code for derived class with virtual destructor sanitizes
its members only once.
Removed patch file containing extraneous changes.

Reviewers: eugenis, kcc

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


Simplified test cases for use-after-dtor

Summary: Simplified test cases to focus on one feature at time.
Tests updated to align with new emission order for sanitizing
callback.

Reviewers: eugenis, kcc

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

Added:
cfe/trunk/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp
cfe/trunk/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=244933&r1=244932&r2=244933&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Aug 13 13:35:11 2015
@@ -1376,9 +1376,30 @@ static void EmitDtorSanitizerCallback(Co
   const ASTRecordLayout &Layout =
   CGF.getContext().getASTRecordLayout(Dtor->getParent());
 
+  // Nothing to poison
+  if(Layout.getFieldCount() == 0)
+return;
+
+  // Construct pointer to region to begin poisoning, and calculate poison
+  // size, so that only members declared in this class are poisoned.
+  llvm::Value *OffsetPtr;
+  CharUnits::QuantityType PoisonSize;
+  ASTContext &Context = CGF.getContext();
+
+  llvm::ConstantInt *OffsetSizePtr = llvm::ConstantInt::get(
+  CGF.SizeTy, Context.toCharUnitsFromBits(Layout.getFieldOffset(0)).
+  getQuantity());
+
+  OffsetPtr = CGF.Builder.CreateGEP(CGF.Builder.CreateBitCast(
+  CGF.LoadCXXThis(), CGF.Int8PtrTy), OffsetSizePtr);
+
+  PoisonSize = Layout.getSize().getQuantity() -
+  Context.toCharUnitsFromBits(Layout.getFieldOffset(0)).getQuantity();
+
   llvm::Value *Args[] = {
-  CGF.Builder.CreateBitCast(CGF.LoadCXXThis(), CGF.VoidPtrTy),
-  llvm::ConstantInt::get(CGF.SizeTy, Layout.getSize().getQuantity())};
+CGF.Builder.CreateBitCast(OffsetPtr, CGF.VoidPtrTy),
+llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
+
   llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
 
   llvm::FunctionType *FnType =
@@ -1386,6 +1407,8 @@ static void EmitDtorSanitizerCallback(Co
   llvm::Value *Fn =
   CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
 
+  // Disables tail call elimination, to prevent the current stack frame from
+  // disappearing from the stack trace.
   CGF.CurFn->addFnAttr("disable-tail-calls", "true");
   CGF.EmitNounwindRuntimeCall(Fn, Args);
 }
@@ -1468,6 +1491,13 @@ void CodeGenFunction::EmitDestructorBody
 // the caller's body.
 if (getLangOpts().AppleKext)
   CurFn->addFnAttr(llvm::Attribute::AlwaysInline);
+
+// Insert memory-poisoning instrumentation, before final clean ups,
+// to ensure this class's members are protected from invalid access.
+if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor
+&& SanOpts.has(SanitizerKind::Memory))
+  EmitDtorSanitizerCallback(*this, Dtor);
+
 break;
   }
 
@@ -1477,11 +1507,6 @@ void CodeGenFunction::EmitDestructorBody
   // Exit the try if applicable.
   if (isTryBody)
 ExitCXXTryStmt(*cast(Body), true);
-
-  // Insert memory-poisoning instrumentation.
-  if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor
-  && SanOpts.has(SanitizerKind::Memory))
-EmitDtorSanitizerCallback(*this, Dtor);
 }
 
 void CodeGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList 
&Args) {

Modified: cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp?rev=244933&r1=244932&r2=244933&view=diff
==
--- cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp Thu Aug 13 13:35:11 
2015
@@ -1,24 +1,26 @@
 // Test -fsanitize-memory-use-after-dtor
 // RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
 
+// Sanitizing dtor is emitted in dtor for every class
+
 struct Simple {
+  int x;
   ~Simple() {}
 };
 Simple s;
 // Simple internal member is poisoned by compiler-generated dt

Re: [PATCH] D12017: Fix IncludeInserter/IncludeSorter bug.

2015-08-13 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Please add a regression test.


http://reviews.llvm.org/D12017



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


Re: [PATCH] D10365: Add cmd to compilation database file format

2015-08-13 Thread Daniel Dilts via cfe-commits
diltsman added a comment.

Where/how does documentation 
(http://clang.llvm.org/docs/JSONCompilationDatabase.html) get updated?


http://reviews.llvm.org/D10365



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


Re: [PATCH] D11844: [Modules] More descriptive diagnostics for misplaced import directive

2015-08-13 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 32085.
sepavloff added a comment.

Updated patch

Thanks to all for fruitful discussion!

The new version tries to addresses review notes. It differs from the previous 
version in:

- Method tryParseMisplacedModuleImport now depends only on current token and is 
used in loop condition. Probably a better name for it is something like 
skipMisplacedModuleImport.
- BalancedDelimiterTracker is updated so that it prints different message if 
module ended before closing bracket has been seen.
- If annot_module_begin is seen where it must not, recovery depends on context. 
Inside a namespace the module is imported as a recovery, a note suggesting to 
move import to top level is issued. Inside a class of a compound statement 
fatal error issued, there is no way to handle this case at upper level.


http://reviews.llvm.org/D11844

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDecl.cpp
  test/Modules/auto-module-import.m
  test/Modules/extern_c.cpp
  test/Modules/malformed.cpp
  test/Modules/misplaced.cpp

Index: test/Modules/misplaced.cpp
===
--- /dev/null
+++ test/Modules/misplaced.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify
+
+namespace N1 {  // expected-note{{namespace 'N1' begins here}}
+#include "dummy.h"  // expected-error{{import of module 'dummy' appears within namespace 'N1'}} \
+// expected-note{{consider moving the import to top level}}
+}
+
+void func1() {  // expected-note{{function 'func1' begins here}}
+#include "dummy.h"  // expected-error{{import of module 'dummy' appears within function 'func1'}} \
+// expected-note{{consider marking the module as textual}}
+}
Index: test/Modules/malformed.cpp
===
--- test/Modules/malformed.cpp
+++ test/Modules/malformed.cpp
@@ -12,20 +12,14 @@
 #include STR(HEADER)
 
 // CHECK-A: While building module 'malformed_a'
-// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} error: expected '}'
+// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} error: expected '}' at the end of module
 // CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} note: to match this '{'
 //
 // CHECK-A: While building module 'malformed_a'
 // CHECK-A: {{^}}Inputs/malformed/a2.h:1:{{.*}} error: extraneous closing brace
 
 // CHECK-B: While building module 'malformed_b'
-// CHECK-B: {{^}}Inputs/malformed/b1.h:2:{{.*}} error: expected '}'
-// CHECK-B: {{^}}Inputs/malformed/b1.h:1:{{.*}} note: to match this '{'
-// CHECK-B: {{^}}Inputs/malformed/b1.h:3:{{.*}} error: extraneous closing brace ('}')
-//
-// CHECK-B: While building module 'malformed_b'
-// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} error: redefinition of 'g'
-// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} note: previous definition is here
+// CHECK-B: {{^}}Inputs/malformed/b1.h:2:{{.*}} error: import of module 'malformed_b.b2' appears within 'S'
 
 void test() { f(); }
 // Test that we use relative paths to name files within an imported module.
Index: test/Modules/extern_c.cpp
===
--- test/Modules/extern_c.cpp
+++ test/Modules/extern_c.cpp
@@ -39,9 +39,11 @@
 #if defined(EXTERN_C) && !defined(EXTERN_CXX) && defined(CXX_HEADER)
 // expected-error@-3 {{import of C++ module 'cxx_library' appears within extern "C" language linkage specification}}
 // expected-note@-17 {{extern "C" language linkage specification begins here}}
+// expected-note@-5 {{consider moving the import to top level}}
 #elif defined(NAMESPACE)
-// expected-error-re@-6 {{import of module '{{c_library.inner|cxx_library}}' appears within namespace 'M'}}
-// expected-note@-24 {{namespace 'M' begins here}}
+// expected-error-re@-7 {{import of module '{{c_library.inner|cxx_library}}' appears within namespace 'M'}}
+// expected-note@-25 {{namespace 'M' begins here}}
+// expected-note@-9 {{consider moving the import to top level}}
 #endif
 
 #ifdef EXTERN_CXX
Index: test/Modules/auto-module-import.m
===
--- test/Modules/auto-module-import.m
+++ test/Modules/auto-module-import.m
@@ -83,6 +83,8 @@
   return not_in_module;
 }
 
-void includeNotAtTopLevel() { // expected-note {{to match this '{'}}
-  #include  // expected-warning {{treating #include as an import}} expected-error {{expected '}'}}
-} // expected-error {{extraneous closing brace}}
+void includeNotAtTopLevel() { // expected-note {{function 'includeNotAtTopLevel' begins here}}
+  #include  // expected-warning {{treating #include as an import}} \
+			   expected-error {{import of module 'NoUmbrella.A'

Re: r244867 - Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.

2015-08-13 Thread Ivan Krasin via cfe-commits
Thank you, Yaron. Understood.

On Thu, Aug 13, 2015 at 11:04 AM, Yaron Keren  wrote:

> There is great variety of OSs, compilers, configs in the bots. You can't
> get the smae with try bots unless everything is duplicated which is a
> waste. You test locally, commit, watch the bots here:
>
>  http://lab.llvm.org:8011/grid
>
> or wait for buildbot failure e-mails which arrive a bit slower.
> Breaks may happen even if you test locally, so it's critical be around
> after the commit to to resolve such issues.
>
>  http://llvm.org/docs/DeveloperPolicy.html#quality
>
>
>
> 2015-08-13 20:51 GMT+03:00 Ivan Krasin :
>
>> Thank you, Yaron.
>>
>> Sorry for breaking the build, it obviously passed locally and I didn't
>> think about all the variety of the supported configs. :(
>>
>> Does LLVM have try bots, so that I can run the tests with my patch before
>> committing it?
>>
>> krasin
>>
>
> On Thu, Aug 13, 2015 at 3:40 AM, Renato Golin 
> wrote:
>
>> On 13 August 2015 at 07:15, Yaron Keren via cfe-commits
>>  wrote:
>> > CHECK-EIGHT is failing bots, see
>> >
>> >
>> http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24306/steps/check-all/logs/FAIL%3A%20Clang%3A%3Adependency-gen.c
>>
>>
>> That check only works if compiler-rt is built in, and supports the
>> target. I wouldn't put that in a Clang test.
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11948: Add some macros to abstract marking of parameters as "not null", and use them in

2015-08-13 Thread Dan Albert via cfe-commits
Because we consider the fact that clang and gcc do this when those
functions are not marked with nonnull by the libc to be a bug. Adding it to
libc++ would just make another place that we have to fix that bug.

What is the objection to using _Nullable instead of __attribute__(nonnull)?
The original motivation in the PSA for this was for better ubsan
diagnostics. _Nullable does that for us, and leaves the decision of whether
null is allowed up to the libc implementers (assuming the compilers are
fixed).
On Aug 13, 2015 07:16, "Marshall Clow"  wrote:

> On Wed, Aug 12, 2015 at 4:03 PM, Dan Albert  wrote:
>
>> My testing was varied. I could not get GCC or clang to optimize it away
>> for Linux, but both did for ARM Android.
>>
>
> Then I don't understand your objection to this change, then.
>
> On your platform, the effect of this change is (therefore) a compile-time
> warning when you pass (a constant) NULL to a set of functions that are
> documented to require non-null parameters.
>
> -- Marshall
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] RE: [cfe-dev] missing return statement for non-void functions in C++

2015-08-13 Thread Gabriel Dos Reis via cfe-commits
Please make such programs crash early and often.  They are a nightmare to
maintain.  Make them blow in the face of the original authors; not after
they are gone.

-- Gaby

On Thu, Aug 13, 2015 at 11:18 AM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Thu, Aug 13, 2015 at 1:52 AM, Sjoerd Meijer 
> wrote:
>
>> Hi Richard,
>>
>> Thanks for reviewing. Agree, that was a bit confusing. More specifically,
>>
>> the warning message was confusing (i.e. wrong). This patch is for
>> compiling .c
>>
>> input in C++ mode. The new flag should be ignored for C++ **input**, and
>> indeed
>>
>> not when it is in C++ *mode* as the warning message said earlier. So I
>> have
>>
>> changed the warning message accordingly and hope that solves it, see
>> attached
>>
>> patch.
>>
>
> What is the distinction you're trying to draw here? This patch still
> doesn't make sense to me. This flag is only meaningful when compiling as
> C++. You ignore it when compiling as C but produce a warning that says it's
> ignored when compiling as C++.
>
>
>> Cheers.
>>
>>
>>
>> *From:* meta...@gmail.com [mailto:meta...@gmail.com] *On Behalf Of *Richard
>> Smith
>> *Sent:* 12 August 2015 23:06
>> *To:* Sjoerd Meijer
>> *Cc:* Hal Finkel; Marshall Clow; cfe-commits
>>
>> *Subject:* Re: [PATCH] RE: [cfe-dev] missing return statement for
>> non-void functions in C++
>>
>>
>>
>> This patch seems a bit confused. You warn that the flag is ignored in
>> C++, but it only has an effect in C++. You have a testcase with a .c
>> extension that is built with -x c++.
>>
>>
>>
>> On Wed, Aug 12, 2015 at 5:23 AM, Sjoerd Meijer 
>> wrote:
>>
>> [ + cfe-commits@lists.llvm.org ]
>>
>>
>>
>> Hi,
>>
>> The functionality is now available under a flag, see attached patch. Note
>> that the flag is ignored in C++ mode, so it will help the use case of
>> compiling (legacy) C code with a C++ compiler.
>>
>> Cheers,
>>
>> Sjoerd.
>>
>>
>>
>> *From:* Sjoerd Meijer [mailto:sjoerd.mei...@arm.com
>> ]
>> *Sent:* 03 August 2015 11:40
>> *To:* 'Richard Smith'
>> *Cc:* Hal Finkel; Marshall Clow; cfe-...@cs.uiuc.edu Developers; cfe
>> commits
>> *Subject:* RE: [PATCH] RE: [cfe-dev] missing return statement for
>> non-void functions in C++
>>
>>
>>
>> Hi Richard,
>>
>>
>>
>> I agree with your conclusions and will start preparing a patch for option
>> 3) under a flag that is off by default; this enables folks to build/run C
>> code in C++. I actually think option 2) would be a good one too, but as it
>> is already available under a flag I also don’t see how useful it is
>> combining options 2) and 3) with another (or one more) flag that is off by
>> default.
>>
>>
>>
>> Cheers.
>>
>>
>>
>> *From:* meta...@gmail.com [mailto:meta...@gmail.com ] *On
>> Behalf Of *Richard Smith
>> *Sent:* 31 July 2015 19:46
>> *To:* Sjoerd Meijer
>> *Cc:* Hal Finkel; Marshall Clow; cfe-...@cs.uiuc.edu Developers; cfe
>> commits
>> *Subject:* Re: [PATCH] RE: [cfe-dev] missing return statement for
>> non-void functions in C++
>>
>>
>>
>> On Fri, Jul 31, 2015 at 7:35 AM, Sjoerd Meijer 
>> wrote:
>>
>> Hi, I am not sure if we came to a conclusion. Please find attached a
>> patch. It simply removes the two lines that insert an unreachable statement
>> (which cause removal of the return statement). Please note that at -O0 the
>> trap instruction is still generated. Is this something we could live with?
>>
>>
>>
>> I don't think this is an improvement:
>>
>>
>>
>> This doesn't satisfy the folks who want an 'unreachable' for better code
>> size and optimization, and it doesn't satisfy the folks who want a
>> guaranteed trap for security, and it doesn't satisfy the folks who want
>> their broken code to limp along (because it'll still trap at -O0), and it
>> is at best a minor improvement for the folks who want missing returns to be
>> more easily debuggable (with -On, the code goes wrong in the caller, or
>> appears to work, rather than falling into an unrelated function, and
>> debugging this with -O0 was already easy).
>>
>>
>>
>> I think there are three options that are defensible here:
>>
>> 1) The status quo: this is UB and we treat it as such and optimize on
>> that basis, but provide a trap as a convenience at -O0
>>
>> 2) The secure approach: this is UB but we always trap
>>
>> 3) Define the behavior to return 'undef' for C types: this allows
>> questionable C code that has UB in C++ to keep working when built with a
>> C++ compiler
>>
>>
>>
>> Note that (3) can be combined with either (1) or (2). (2) is already
>> available via the 'return' sanitizer. So this really reduces to: in those
>> cases where C says it's OK so long as the caller doesn't look at the
>> returned value (and where the return type doesn't have a non-trivial copy
>> constructor or destructor, isn't a reference, and so on), should we attempt
>> to preserve the C behaviour? I would be OK with putting that behind a `-f`
>> flag (perhaps `-fstrict-return` or similar) to support those folks who want
>> to build C 

Re: [PATCH] D11948: Add some macros to abstract marking of parameters as "not null", and use them in

2015-08-13 Thread Stephen Hines via cfe-commits
I don't see anywhere in the C standard that says that a memcpy() with NULL
for either pointer is UB (which would only be valid for the case where n ==
0). This seems like a particularly aggressive (mis)optimization in the
general case. It should only be acceptable if the length is guaranteed to
be nonzero. That doesn't seem to be how the optimizers work today,
unfortunately.

Steve

On Thu, Aug 13, 2015 at 1:47 PM, Dan Albert via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Because we consider the fact that clang and gcc do this when those
> functions are not marked with nonnull by the libc to be a bug. Adding it to
> libc++ would just make another place that we have to fix that bug.
>
> What is the objection to using _Nullable instead of
> __attribute__(nonnull)? The original motivation in the PSA for this was for
> better ubsan diagnostics. _Nullable does that for us, and leaves the
> decision of whether null is allowed up to the libc implementers (assuming
> the compilers are fixed).
> On Aug 13, 2015 07:16, "Marshall Clow"  wrote:
>
>> On Wed, Aug 12, 2015 at 4:03 PM, Dan Albert  wrote:
>>
>>> My testing was varied. I could not get GCC or clang to optimize it away
>>> for Linux, but both did for ARM Android.
>>>
>>
>> Then I don't understand your objection to this change, then.
>>
>> On your platform, the effect of this change is (therefore) a compile-time
>> warning when you pass (a constant) NULL to a set of functions that are
>> documented to require non-null parameters.
>>
>> -- Marshall
>>
>>
>>
> ___
> 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] D11948: Add some macros to abstract marking of parameters as "not null", and use them in

2015-08-13 Thread Aaron Ballman via cfe-commits
On Thu, Aug 13, 2015 at 4:53 PM, Stephen Hines via cfe-commits
 wrote:
> I don't see anywhere in the C standard that says that a memcpy() with NULL
> for either pointer is UB (which would only be valid for the case where n ==
> 0). This seems like a particularly aggressive (mis)optimization in the
> general case. It should only be acceptable if the length is guaranteed to be
> nonzero. That doesn't seem to be how the optimizers work today,
> unfortunately.

7.24.1p2 (in part):
Where an argument declared as size_t n specifies the length of the
array for a function, n can have the value zero on a call to that
function. Unless explicitly stated otherwise in the description of a
particular function in this subclause, pointer arguments on such a
call shall still have valid values, as described in 7.1.4.

7.1.4p1 (in part):
If an argument to a function has an invalid value (such as a value
outside the domain of the function, or a pointer outside the address
space of the program, or a null pointer, or a pointer to
non-modifiable storage when the corresponding parameter is not
const-qualified) or a type (after promotion) not expected by a
function with variable number of arguments, the behavior is undefined.

While memcpy isn't a function with a variable number of arguments, I
believe the "as described in 7.1.4" is referring to the description of
invalid values. The fact that it is a shall clause in 7.24.1 means
that violation results in undefined behavior. At least, that is my
interpretation of the standard.

~Aaron

>
> Steve
>
> On Thu, Aug 13, 2015 at 1:47 PM, Dan Albert via cfe-commits
>  wrote:
>>
>> Because we consider the fact that clang and gcc do this when those
>> functions are not marked with nonnull by the libc to be a bug. Adding it to
>> libc++ would just make another place that we have to fix that bug.
>>
>> What is the objection to using _Nullable instead of
>> __attribute__(nonnull)? The original motivation in the PSA for this was for
>> better ubsan diagnostics. _Nullable does that for us, and leaves the
>> decision of whether null is allowed up to the libc implementers (assuming
>> the compilers are fixed).
>>
>> On Aug 13, 2015 07:16, "Marshall Clow"  wrote:
>>>
>>> On Wed, Aug 12, 2015 at 4:03 PM, Dan Albert  wrote:

 My testing was varied. I could not get GCC or clang to optimize it away
 for Linux, but both did for ARM Android.
>>>
>>>
>>> Then I don't understand your objection to this change, then.
>>>
>>> On your platform, the effect of this change is (therefore) a compile-time
>>> warning when you pass (a constant) NULL to a set of functions that are
>>> documented to require non-null parameters.
>>>
>>> -- Marshall
>>>
>>>
>>
>> ___
>> 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11629: APValues and Constants and MaterializedTemporaryExpr need to have stable maps

2015-08-13 Thread Justin Bogner via cfe-commits
David Majnemer  writes:
> majnemer created this revision.
> majnemer added a reviewer: rsmith.
> majnemer added a subscriber: cfe-commits.
>
> We risk iterator invalidation issues if we use DenseMap structures for
> MaterializedTemporaryExprs.  Use a std::map to ensure that they don't
> move around in memory.
>
> This fixes PR24289.
>
> http://reviews.llvm.org/D11629
>
> Files:
>   include/clang/AST/ASTContext.h
>   lib/AST/ASTContext.cpp
>   lib/CodeGen/CodeGenModule.h
>   test/CodeGenCXX/PR24289.cpp
>
> Index: test/CodeGenCXX/PR24289.cpp
> ===
> --- /dev/null
> +++ test/CodeGenCXX/PR24289.cpp
> @@ -0,0 +1,82 @@
> +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu -std=c++11 
> | FileCheck %s
> +
> +namespace std {
> +template 
> +struct initializer_list {
> +  const T *Begin;
> +  __SIZE_TYPE__ Size;
> +
> +  constexpr initializer_list(const T *B, __SIZE_TYPE__ S)
> +  : Begin(B), Size(S) {}
> +};
> +}
> +
> +void f() {
> +  static std::initializer_list> a{
> +  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
> +  static std::initializer_list> b{
> +  {0}, {0}, {0}, {0}};
> +  static std::initializer_list> c{
> +  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
> +  static std::initializer_list> d{
> +  {0}, {0}, {0}, {0}, {0}};
> +  static std::initializer_list> e{
> +  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
> +}
> +
> +// CHECK-DAG: @_ZZ1fvE1a = internal global %{{.*}} { %{{.*}}* getelementptr 
> inbounds ([14 x %{{.*}}], [14 x %{{.*}}]
> +// CHECK-DAG: * @_ZGRZ1fvE1a_, i32 0, i32 0), i64 14 }
> +// CHECK-DAG: @_ZGRZ1fvE1a0_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a1_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a2_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a3_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a4_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a5_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a6_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a7_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a8_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a9_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1aA_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1aB_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1aC_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1aD_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1a_ = internal constant [14 x %{{.*}}] [%{{.*}} { 
> i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a0_, i32 0, i32 
> 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
> @_ZGRZ1fvE1a1_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds 
> ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a2_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* 
> getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a3_, i32 0, i32 0), 
> i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
> @_ZGRZ1fvE1a4_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds 
> ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a5_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* 
> getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a6_, i32 0, i32 0), 
> i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
> @_ZGRZ1fvE1a7_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds 
> ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a8_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* 
> getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a9_, i32 0, i32 0), 
> i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
> @_ZGRZ1fvE1aA_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds 
> ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aB_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* 
> getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aC_, i32 0, i32 0), 
> i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* 
> @_ZGRZ1fvE1aD_, i32 0, i32 0), i64 1 }]
> +// CHECK-DAG: @_ZZ1fvE1b = internal global %{{.*}} { %{{.*}}* getelementptr 
> inbounds ([4 x %{{.*}}], [4 x %{{.*}}]*
> +// CHECK-DAG: @_ZGRZ1fvE1b_, i32 0, i32 0), i64 4 }
> +// CHECK-DAG: @_ZGRZ1fvE1b0_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1b1_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1b2_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1b3_ = internal constant [1 x i32] zeroinitializer
> +// CHECK-DAG: @_ZGRZ1fvE1b_ = internal constant [4 x %{{.*}}] [%{{.*}} { 
> i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1b0_, i32 0, i32 
> 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 

r244956 - Wdeprecated: Replace deprecated throw() with LLVM_NOEXCEPT which expands to 'noexcept' where available (and throw() otherwise)

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 16:15:23 2015
New Revision: 244956

URL: http://llvm.org/viewvc/llvm-project?rev=244956&view=rev
Log:
Wdeprecated: Replace deprecated throw() with LLVM_NOEXCEPT which expands to 
'noexcept' where available (and throw() otherwise)

Modified:
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Lex/PreprocessingRecord.h

Modified: cfe/trunk/include/clang/AST/Attr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Attr.h?rev=244956&r1=244955&r2=244956&view=diff
==
--- cfe/trunk/include/clang/AST/Attr.h (original)
+++ cfe/trunk/include/clang/AST/Attr.h Thu Aug 13 16:15:23 2015
@@ -56,21 +56,21 @@ protected:
   bool IsLateParsed : 1;
   bool DuplicatesAllowed : 1;
 
-  void* operator new(size_t bytes) throw() {
+  void *operator new(size_t bytes) LLVM_NOEXCEPT {
 llvm_unreachable("Attrs cannot be allocated with regular 'new'.");
   }
-  void operator delete(void* data) throw() {
+  void operator delete(void *data) LLVM_NOEXCEPT {
 llvm_unreachable("Attrs cannot be released with regular 'delete'.");
   }
 
 public:
   // Forward so that the regular new and delete do not hide global ones.
-  void* operator new(size_t Bytes, ASTContext &C,
- size_t Alignment = 8) throw() {
+  void *operator new(size_t Bytes, ASTContext &C,
+ size_t Alignment = 8) LLVM_NOEXCEPT {
 return ::operator new(Bytes, C, Alignment);
   }
   void operator delete(void *Ptr, ASTContext &C,
-   size_t Alignment) throw() {
+   size_t Alignment) LLVM_NOEXCEPT {
 return ::operator delete(Ptr, C, Alignment);
   }
 

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=244956&r1=244955&r2=244956&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Thu Aug 13 16:15:23 2015
@@ -71,10 +71,10 @@ public:
 
   // Make vanilla 'new' and 'delete' illegal for Stmts.
 protected:
-  void* operator new(size_t bytes) throw() {
+  void *operator new(size_t bytes) LLVM_NOEXCEPT {
 llvm_unreachable("Stmts cannot be allocated with regular 'new'.");
   }
-  void operator delete(void* data) throw() {
+  void operator delete(void *data) LLVM_NOEXCEPT {
 llvm_unreachable("Stmts cannot be released with regular 'delete'.");
   }
 
@@ -272,14 +272,12 @@ public:
 return operator new(bytes, *C, alignment);
   }
 
-  void* operator new(size_t bytes, void* mem) throw() {
-return mem;
-  }
+  void *operator new(size_t bytes, void *mem) LLVM_NOEXCEPT { return mem; }
 
-  void operator delete(void*, const ASTContext&, unsigned) throw() { }
-  void operator delete(void*, const ASTContext*, unsigned) throw() { }
-  void operator delete(void*, size_t) throw() { }
-  void operator delete(void*, void*) throw() { }
+  void operator delete(void *, const ASTContext &, unsigned) LLVM_NOEXCEPT {}
+  void operator delete(void *, const ASTContext *, unsigned) LLVM_NOEXCEPT {}
+  void operator delete(void *, size_t) LLVM_NOEXCEPT {}
+  void operator delete(void *, void *) LLVM_NOEXCEPT {}
 
 public:
   /// \brief A placeholder type used to construct an empty shell of a

Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=244956&r1=244955&r2=244956&view=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Thu Aug 13 16:15:23 2015
@@ -32,12 +32,12 @@ namespace clang {
 }
 
 /// \brief Allocates memory within a Clang preprocessing record.
-void* operator new(size_t bytes, clang::PreprocessingRecord& PR,
-   unsigned alignment = 8) throw();
+void *operator new(size_t bytes, clang::PreprocessingRecord &PR,
+   unsigned alignment = 8) LLVM_NOEXCEPT;
 
 /// \brief Frees memory allocated in a Clang preprocessing record.
 void operator delete(void *ptr, clang::PreprocessingRecord &PR,
- unsigned) throw();
+ unsigned) LLVM_NOEXCEPT;
 
 namespace clang {
   class MacroDefinitionRecord;
@@ -98,27 +98,25 @@ namespace clang {
 
 // Only allow allocation of preprocessed entities using the allocator 
 // in PreprocessingRecord or by doing a placement new.
-void* operator new(size_t bytes, PreprocessingRecord& PR,
-   unsigned alignment = 8) throw() {
+void *operator new(size_t bytes, PreprocessingRecord &PR,
+   unsigned alignment = 8) LLVM_NOEXCEPT {
   return ::operator new(bytes, PR, alignment);
 }
-
-void* operator new(size_t byt

Re: [PATCH] D11948: Add some macros to abstract marking of parameters as "not null", and use them in

2015-08-13 Thread Chandler Carruth via cfe-commits
chandlerc added a comment.

I agree with both Marshall and Hal.

However, I'm also not opposed to platforms opting out if this if they want to. 
If a particular platform wants to define the behavior of null pointers passed 
to these functions, that seems like a reasonable thing to support here. The two 
platforms that seem interested in supporting null pointers here are Android and 
FreeBSD, so I think we should disable this for those platforms.

But I want to point out and emphasize what Hal said: the compiler can *already 
do this*. Please make sure that both of those platforms configure Clang and 
LLVM to specially handle these routines to support null pointers. You're 
providing a conforming extension for your platform, but you can't *just* do 
that in the STL, you need to do that at every layer of the toolchain.

For Linux, given the *very* long precedent of glibc and GCC behavior, I'm 
confident we want these annotations. I'll let folks that actually support other 
platforms chime up for the cases they care about.


http://reviews.llvm.org/D11948



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


r244957 - Wdeprecated: LambdaScopeInfos are copied in TreeTransform, so make sure they're copyable.

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 16:23:08 2015
New Revision: 244957

URL: http://llvm.org/viewvc/llvm-project?rev=244957&view=rev
Log:
Wdeprecated: LambdaScopeInfos are copied in TreeTransform, so make sure they're 
copyable.

Partly addressed by r244843, but the explicit dtor in LambdaScopeInfo
was still thwarting the implicit copy ctor. This does remove the key
function from LambdaScopeInfo unfortunately, but it seems neater than
having to explicitly default any special members LambdaScopeInfo needs.

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

Modified: cfe/trunk/include/clang/Sema/ScopeInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ScopeInfo.h?rev=244957&r1=244956&r2=244957&view=diff
==
--- cfe/trunk/include/clang/Sema/ScopeInfo.h (original)
+++ cfe/trunk/include/clang/Sema/ScopeInfo.h Thu Aug 13 16:23:08 2015
@@ -703,8 +703,6 @@ public:
 Kind = SK_Lambda;
   }
 
-  ~LambdaScopeInfo() override;
-
   /// \brief Note when all explicit captures have been added.
   void finishedExplicitCaptures() {
 NumExplicitCaptures = Captures.size();

Modified: cfe/trunk/lib/Sema/ScopeInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ScopeInfo.cpp?rev=244957&r1=244956&r2=244957&view=diff
==
--- cfe/trunk/lib/Sema/ScopeInfo.cpp (original)
+++ cfe/trunk/lib/Sema/ScopeInfo.cpp Thu Aug 13 16:23:08 2015
@@ -234,5 +234,4 @@ void LambdaScopeInfo::getPotentialVariab
 
 FunctionScopeInfo::~FunctionScopeInfo() { }
 BlockScopeInfo::~BlockScopeInfo() { }
-LambdaScopeInfo::~LambdaScopeInfo() { }
 CapturedRegionScopeInfo::~CapturedRegionScopeInfo() { }


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


r244958 - Wdeprecated: CommentVerifiers are returned by value, make sure they're correctly copy/moveable

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 16:24:08 2015
New Revision: 244958

URL: http://llvm.org/viewvc/llvm-project?rev=244958&view=rev
Log:
Wdeprecated: CommentVerifiers are returned by value, make sure they're 
correctly copy/moveable

Modified:
cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp

Modified: cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp?rev=244958&r1=244957&r2=244958&view=diff
==
--- cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/CommentHandlerTest.cpp Thu Aug 13 16:24:08 2015
@@ -97,6 +97,10 @@ public:
   : Current(Comments.begin()), End(Comments.end()), PP(PP)
 { }
 
+  CommentVerifier(CommentVerifier &&C) : Current(C.Current), End(C.End), 
PP(C.PP) {
+C.Current = C.End;
+  }
+
   ~CommentVerifier() {
 if (Current != End) {
   EXPECT_TRUE(Current == End) << "Unexpected comment \""


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


r244959 - Fix some coding standard issues and delete a dead conditional.

2015-08-13 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Thu Aug 13 16:34:35 2015
New Revision: 244959

URL: http://llvm.org/viewvc/llvm-project?rev=244959&view=rev
Log:
Fix some coding standard issues and delete a dead conditional.

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

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=244959&r1=244958&r2=244959&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Aug 13 16:34:35 2015
@@ -2491,17 +2491,17 @@ static void handleFormatArgAttr(Sema &S,
   if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, IdxExpr, Idx))
 return;
 
-  // make sure the format string is really a string
+  // Make sure the format string is really a string.
   QualType Ty = getFunctionOrMethodParamType(D, Idx);
 
-  bool not_nsstring_type = !isNSStringType(Ty, S.Context);
-  if (not_nsstring_type &&
+  bool NotNSStringTy = !isNSStringType(Ty, S.Context);
+  if (NotNSStringTy &&
   !isCFStringType(Ty, S.Context) &&
   (!Ty->isPointerType() ||
!Ty->getAs()->getPointeeType()->isCharType())) {
 S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
-<< (not_nsstring_type ? "a string type" : "an NSString")
-<< IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0);
+<< "a string type" << IdxExpr->getSourceRange()
+<< getFunctionOrMethodParamRange(D, 0);
 return;
   }
   Ty = getFunctionOrMethodResultType(D);
@@ -2510,7 +2510,7 @@ static void handleFormatArgAttr(Sema &S,
   (!Ty->isPointerType() ||
!Ty->getAs()->getPointeeType()->isCharType())) {
 S.Diag(Attr.getLoc(), diag::err_format_attribute_result_not)
-<< (not_nsstring_type ? "string type" : "NSString")
+<< (NotNSStringTy ? "string type" : "NSString")
 << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0);
 return;
   }


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


r244961 - [SPARC] Fix types of size_t, intptr_t, and ptrdiff_t on OpenBSD.

2015-08-13 Thread Brad Smith via cfe-commits
Author: brad
Date: Thu Aug 13 16:45:57 2015
New Revision: 244961

URL: http://llvm.org/viewvc/llvm-project?rev=244961&view=rev
Log:
[SPARC] Fix types of size_t, intptr_t, and ptrdiff_t on OpenBSD.

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=244961&r1=244960&r2=244961&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Aug 13 16:45:57 2015
@@ -5726,16 +5726,19 @@ class SparcV8TargetInfo : public SparcTa
 public:
   SparcV8TargetInfo(const llvm::Triple &Triple) : SparcTargetInfo(Triple) {
 DataLayoutString = "E-m:e-p:32:32-i64:64-f128:64-n32-S64";
-// NetBSD uses long (same as llvm default); everyone else uses int.
-if (getTriple().getOS() == llvm::Triple::NetBSD) {
-  SizeType = UnsignedLong;
-  IntPtrType = SignedLong;
-  PtrDiffType = SignedLong;
-} else {
+// NetBSD / OpenBSD use long (same as llvm default); everyone else uses 
int.
+switch (getTriple().getOS()) {
+default:
   SizeType = UnsignedInt;
   IntPtrType = SignedInt;
   PtrDiffType = SignedInt;
-}
+  break;
+case llvm::Triple::NetBSD:
+case llvm::Triple::OpenBSD:
+  SizeType = UnsignedLong;
+  IntPtrType = SignedLong;
+  PtrDiffType = SignedLong;
+  break;
   }
 
   void getTargetDefines(const LangOptions &Opts,

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=244961&r1=244960&r2=244961&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Thu Aug 13 16:45:57 2015
@@ -6984,14 +6984,15 @@
 // SPARC:#define __sparcv8 1
 // SPARC:#define sparc 1
 // 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-netbsd < /dev/null 
| FileCheck -check-prefix SPARC-NETBSD %s
-// SPARC-NETBSD:#define __INTPTR_FMTd__ "ld"
-// SPARC-NETBSD:#define __INTPTR_FMTi__ "li"
-// SPARC-NETBSD:#define __INTPTR_MAX__ 2147483647L
-// SPARC-NETBSD:#define __INTPTR_TYPE__ long int
-// SPARC-NETBSD:#define __PTRDIFF_TYPE__ long int
-// SPARC-NETBSD:#define __SIZE_TYPE__ long unsigned int
-// SPARC-NETBSD:#define __UINTPTR_TYPE__ long unsigned int
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-netbsd < /dev/null 
| FileCheck -check-prefix SPARC-NETOPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-openbsd < 
/dev/null | FileCheck -check-prefix SPARC-NETOPENBSD %s
+// SPARC-NETOPENBSD:#define __INTPTR_FMTd__ "ld"
+// SPARC-NETOPENBSD:#define __INTPTR_FMTi__ "li"
+// SPARC-NETOPENBSD:#define __INTPTR_MAX__ 2147483647L
+// SPARC-NETOPENBSD:#define __INTPTR_TYPE__ long int
+// SPARC-NETOPENBSD:#define __PTRDIFF_TYPE__ long int
+// SPARC-NETOPENBSD:#define __SIZE_TYPE__ long unsigned int
+// SPARC-NETOPENBSD:#define __UINTPTR_TYPE__ long unsigned int
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=tce-none-none < /dev/null | 
FileCheck -check-prefix TCE %s
 //


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


Re: r244961 - [SPARC] Fix types of size_t, intptr_t, and ptrdiff_t on OpenBSD.

2015-08-13 Thread Hans Wennborg via cfe-commits
On Thu, Aug 13, 2015 at 2:45 PM, Brad Smith via cfe-commits
 wrote:
> Author: brad
> Date: Thu Aug 13 16:45:57 2015
> New Revision: 244961
>
> URL: http://llvm.org/viewvc/llvm-project?rev=244961&view=rev
> Log:
> [SPARC] Fix types of size_t, intptr_t, and ptrdiff_t on OpenBSD.
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/test/Preprocessor/init.c

This seems to have broken the build. For example, from
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/29920/steps/compile/logs/stdio:

/home/llvmbb/llvm-build-dir/clang-x86_64-debian-fast/llvm.src/tools/clang/lib/Basic/Targets.cpp:5752:36:
error: base class has incomplete type
class SparcV8elTargetInfo : public SparcV8TargetInfo {
~~~^
/home/llvmbb/llvm-build-dir/clang-x86_64-debian-fast/llvm.src/tools/clang/lib/Basic/Targets.cpp:5725:7:
note: definition of '(anonymous namespace)::SparcV8TargetInfo' is not
complete until the closing '}'
class SparcV8TargetInfo : public SparcTargetInfo {
  ^
/home/llvmbb/llvm-build-dir/clang-x86_64-debian-fast/llvm.src/tools/clang/lib/Basic/Targets.cpp:5929:40:
error: non-friend class member 'BuiltinInfo' cannot have a qualified
name
const Builtin::Info SystemZTargetInfo::BuiltinInfo[] = {
~~~^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r244962 - Removed one too many braces.

2015-08-13 Thread Brad Smith via cfe-commits
Author: brad
Date: Thu Aug 13 17:00:53 2015
New Revision: 244962

URL: http://llvm.org/viewvc/llvm-project?rev=244962&view=rev
Log:
Removed one too many braces.

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=244962&r1=244961&r2=244962&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Aug 13 17:00:53 2015
@@ -5739,6 +5739,7 @@ public:
   IntPtrType = SignedLong;
   PtrDiffType = SignedLong;
   break;
+}
   }
 
   void getTargetDefines(const LangOptions &Opts,


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


Re: [PATCH] D11629: APValues and Constants and MaterializedTemporaryExpr need to have stable maps

2015-08-13 Thread David Majnemer via cfe-commits
On Thu, Aug 13, 2015 at 5:15 PM, Justin Bogner 
wrote:

> David Majnemer  writes:
> > majnemer created this revision.
> > majnemer added a reviewer: rsmith.
> > majnemer added a subscriber: cfe-commits.
> >
> > We risk iterator invalidation issues if we use DenseMap structures for
> > MaterializedTemporaryExprs.  Use a std::map to ensure that they don't
> > move around in memory.
> >
> > This fixes PR24289.
> >
> > http://reviews.llvm.org/D11629
> >
> > Files:
> >   include/clang/AST/ASTContext.h
> >   lib/AST/ASTContext.cpp
> >   lib/CodeGen/CodeGenModule.h
> >   test/CodeGenCXX/PR24289.cpp
> >
> > Index: test/CodeGenCXX/PR24289.cpp
> > ===
> > --- /dev/null
> > +++ test/CodeGenCXX/PR24289.cpp
> > @@ -0,0 +1,82 @@
> > +// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu
> -std=c++11 | FileCheck %s
> > +
> > +namespace std {
> > +template 
> > +struct initializer_list {
> > +  const T *Begin;
> > +  __SIZE_TYPE__ Size;
> > +
> > +  constexpr initializer_list(const T *B, __SIZE_TYPE__ S)
> > +  : Begin(B), Size(S) {}
> > +};
> > +}
> > +
> > +void f() {
> > +  static std::initializer_list> a{
> > +  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
> {0}};
> > +  static std::initializer_list> b{
> > +  {0}, {0}, {0}, {0}};
> > +  static std::initializer_list> c{
> > +  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
> > +  static std::initializer_list> d{
> > +  {0}, {0}, {0}, {0}, {0}};
> > +  static std::initializer_list> e{
> > +  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
> > +}
> > +
> > +// CHECK-DAG: @_ZZ1fvE1a = internal global %{{.*}} { %{{.*}}*
> getelementptr inbounds ([14 x %{{.*}}], [14 x %{{.*}}]
> > +// CHECK-DAG: * @_ZGRZ1fvE1a_, i32 0, i32 0), i64 14 }
> > +// CHECK-DAG: @_ZGRZ1fvE1a0_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a1_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a2_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a3_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a4_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a5_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a6_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a7_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a8_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a9_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1aA_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1aB_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1aC_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1aD_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1a_ = internal constant [14 x %{{.*}}] [%{{.*}}
> { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a0_, i32 0,
> i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x
> i32]* @_ZGRZ1fvE1a1_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr
> inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a2_, i32 0, i32 0), i64 1 },
> %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]*
> @_ZGRZ1fvE1a3_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr
> inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a4_, i32 0, i32 0), i64 1 },
> %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]*
> @_ZGRZ1fvE1a5_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr
> inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a6_, i32 0, i32 0), i64 1 },
> %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]*
> @_ZGRZ1fvE1a7_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr
> inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a8_, i32 0, i32 0), i64 1 },
> %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]*
> @_ZGRZ1fvE1a9_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr
> inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aA_, i32 0, i32 0), i64 1 },
> %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]*
> @_ZGRZ1fvE1aB_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr
> inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aC_, i32 0, i32 0), i64 1 },
> %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]*
> @_ZGRZ1fvE1aD_, i32 0, i32 0), i64 1 }]
> > +// CHECK-DAG: @_ZZ1fvE1b = internal global %{{.*}} { %{{.*}}*
> getelementptr inbounds ([4 x %{{.*}}], [4 x %{{.*}}]*
> > +// CHECK-DAG: @_ZGRZ1fvE1b_, i32 0, i32 0), i64 4 }
> > +// CHECK-DAG: @_ZGRZ1fvE1b0_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1b1_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1b2_ = internal constant [1 x i32]
> zeroinitializer
> > +// CHECK-DAG: @_ZGRZ1fvE1b3_ = internal constant [1 x i32]
> zeroiniti

Re: [PATCH] D11629: APValues and Constants and MaterializedTemporaryExpr need to have stable maps

2015-08-13 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/AST/ASTContext.h:180
@@ -179,3 +179,3 @@
   /// that appear in constant initializers to their evaluated values.
-  llvm::DenseMap
+  std::map
 MaterializedTemporaryValues;

I would prefer a `DenseMap`, with 
`APValue`s allocated by the `ASTContext`'s `BumpPtrAllocator`.


http://reviews.llvm.org/D11629



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


r244968 - Wdeprecated: Make BumpVectorContext movable

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 17:12:21 2015
New Revision: 244968

URL: http://llvm.org/viewvc/llvm-project?rev=244968&view=rev
Log:
Wdeprecated: Make BumpVectorContext movable

Turns out the one place that relied on the implicit copy ctor was safe
because it created an object in a state where the dtor was a no-op, but
that's more luck that good management.

Sure up the API by defining move construction and using it, which
implicitly disallows the unreliable copy operations.

Modified:
cfe/trunk/include/clang/Analysis/Support/BumpVector.h
cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/include/clang/Analysis/Support/BumpVector.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Support/BumpVector.h?rev=244968&r1=244967&r2=244968&view=diff
==
--- cfe/trunk/include/clang/Analysis/Support/BumpVector.h (original)
+++ cfe/trunk/include/clang/Analysis/Support/BumpVector.h Thu Aug 13 17:12:21 
2015
@@ -35,7 +35,12 @@ public:
   /// Construct a new BumpVectorContext that creates a new BumpPtrAllocator
   /// and destroys it when the BumpVectorContext object is destroyed.
   BumpVectorContext() : Alloc(new llvm::BumpPtrAllocator(), 1) {}
-  
+
+  BumpVectorContext(BumpVectorContext &&Other) : Alloc(Other.Alloc) {
+Other.Alloc.setInt(false);
+Other.Alloc.setPointer(nullptr);
+  }
+
   /// Construct a new BumpVectorContext that reuses an existing
   /// BumpPtrAllocator.  This BumpPtrAllocator is not destroyed when the
   /// BumpVectorContext object is destroyed.

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=244968&r1=244967&r2=244968&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Thu Aug 13 17:12:21 2015
@@ -176,8 +176,8 @@ private:
 
 public:
   /// Constructs empty scope linked to previous scope in specified place.
-  LocalScope(BumpVectorContext &ctx, const_iterator P)
-  : ctx(ctx), Vars(ctx, 4), Prev(P) {}
+  LocalScope(BumpVectorContext ctx, const_iterator P)
+  : ctx(std::move(ctx)), Vars(this->ctx, 4), Prev(P) {}
 
   /// Begin of scope in direction of CFG building (backwards).
   const_iterator begin() const { return const_iterator(*this, Vars.size()); }
@@ -1247,13 +1247,11 @@ void CFGBuilder::addImplicitDtorsForDest
 /// createOrReuseLocalScope - If Scope is NULL create new LocalScope. Either
 /// way return valid LocalScope object.
 LocalScope* CFGBuilder::createOrReuseLocalScope(LocalScope* Scope) {
-  if (!Scope) {
-llvm::BumpPtrAllocator &alloc = cfg->getAllocator();
-Scope = alloc.Allocate();
-BumpVectorContext ctx(alloc);
-new (Scope) LocalScope(ctx, ScopePos);
-  }
-  return Scope;
+  if (Scope)
+return Scope;
+  llvm::BumpPtrAllocator &alloc = cfg->getAllocator();
+  return new (alloc.Allocate())
+  LocalScope(BumpVectorContext(alloc), ScopePos);
 }
 
 /// addLocalScopeForStmt - Add LocalScope to local scopes tree for statement


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


r244970 - clang/test/Frontend/dependency-gen.c: Add explicit -target x86_64-linux-gnu for -fsanitize.

2015-08-13 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Thu Aug 13 17:17:34 2015
New Revision: 244970

URL: http://llvm.org/viewvc/llvm-project?rev=244970&view=rev
Log:
clang/test/Frontend/dependency-gen.c: Add explicit -target x86_64-linux-gnu for 
-fsanitize.

Modified:
cfe/trunk/test/Frontend/dependency-gen.c

Modified: cfe/trunk/test/Frontend/dependency-gen.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/dependency-gen.c?rev=244970&r1=244969&r2=244970&view=diff
==
--- cfe/trunk/test/Frontend/dependency-gen.c (original)
+++ cfe/trunk/test/Frontend/dependency-gen.c Thu Aug 13 17:17:34 2015
@@ -24,9 +24,9 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=address -flto -I . | 
FileCheck -check-prefix=CHECK-EIGHT %s
+// RUN: %clang -target x86_64-linux-gnu -MD -MF - %s -fsyntax-only 
-fsanitize=address -flto -I . | FileCheck -check-prefix=CHECK-EIGHT %s
 // CHECK-EIGHT: {{ }}x.h
-// RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=address -flto -I . 
-fno-sanitize-blacklist | FileCheck -check-prefix=CHECK-NINE %s
+// RUN: %clang -target x86_64-linux-gnu -MD -MF - %s -fsyntax-only 
-fsanitize=address -flto -I . -fno-sanitize-blacklist | FileCheck 
-check-prefix=CHECK-NINE %s
 // CHECK-NINE-NOT: asan_blacklist.txt
 // CHECK-NINE: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST


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


r244971 - Wdeprecated: StoredDiagnostics are stored in a SmallVector, so make sure they're copy/movable

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 17:20:14 2015
New Revision: 244971

URL: http://llvm.org/viewvc/llvm-project?rev=244971&view=rev
Log:
Wdeprecated: StoredDiagnostics are stored in a SmallVector, so make sure 
they're copy/movable

Removing the no-op dtor makes these objects safely implicitly
copyable/movable/etc.

(& tidy up the ctor, while I'm here)

Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/Basic/Diagnostic.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=244971&r1=244970&r2=244971&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Thu Aug 13 17:20:14 2015
@@ -1264,7 +1264,7 @@ class StoredDiagnostic {
   std::vector FixIts;
 
 public:
-  StoredDiagnostic();
+  StoredDiagnostic() = default;
   StoredDiagnostic(DiagnosticsEngine::Level Level, const Diagnostic &Info);
   StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID, 
StringRef Message);
@@ -1272,7 +1272,6 @@ public:
StringRef Message, FullSourceLoc Loc,
ArrayRef Ranges,
ArrayRef Fixits);
-  ~StoredDiagnostic();
 
   /// \brief Evaluates true when this object stores a diagnostic.
   explicit operator bool() const { return Message.size() > 0; }

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=244971&r1=244970&r2=244971&view=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Aug 13 17:20:14 2015
@@ -945,8 +945,6 @@ FormatDiagnostic(const char *DiagStr, co
   OutStr.append(Tree.begin(), Tree.end());
 }
 
-StoredDiagnostic::StoredDiagnostic() { }
-
 StoredDiagnostic::StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID,
StringRef Message)
   : ID(ID), Level(Level), Loc(), Message(Message) { }
@@ -975,8 +973,6 @@ StoredDiagnostic::StoredDiagnostic(Diagn
 {
 }
 
-StoredDiagnostic::~StoredDiagnostic() { }
-
 /// IncludeInDiagnosticCounts - This method (whose default implementation
 ///  returns true) indicates whether the diagnostics handled by this
 ///  DiagnosticConsumer should be included in the number of diagnostics


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


r244973 - Wdeprecated: PathPieces are copied, make them safely implicitly copyable by removing the unnecessary user declared dtor.

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 17:23:53 2015
New Revision: 244973

URL: http://llvm.org/viewvc/llvm-project?rev=244973&view=rev
Log:
Wdeprecated: PathPieces are copied, make them safely implicitly copyable by 
removing the unnecessary user declared dtor.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h?rev=244973&r1=244972&r2=244973&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
Thu Aug 13 17:23:53 2015
@@ -422,7 +422,6 @@ class PathPieces : public std::listhttp://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp?rev=244973&r1=244972&r2=244973&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Thu Aug 13 17:23:53 
2015
@@ -62,8 +62,6 @@ PathDiagnosticControlFlowPiece::~PathDia
 PathDiagnosticMacroPiece::~PathDiagnosticMacroPiece() {}
 
 
-PathPieces::~PathPieces() {}
-
 void PathPieces::flattenTo(PathPieces &Primary, PathPieces &Current,
bool ShouldFlattenMacros) const {
   for (PathPieces::const_iterator I = begin(), E = end(); I != E; ++I) {


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


Re: [PATCH] D10365: Add cmd to compilation database file format

2015-08-13 Thread Daniel Dilts via cfe-commits
diltsman updated this revision to Diff 32099.
diltsman marked an inline comment as done.
diltsman added a comment.

Added test for command and arguments in same object.
Fixed bug where parse failed if command and argument resolved to empty lists.


http://reviews.llvm.org/D10365

Files:
  ../llvm/tools/clang/include/clang/Tooling/JSONCompilationDatabase.h
  ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp
  ../llvm/tools/clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: ../llvm/tools/clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- ../llvm/tools/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ ../llvm/tools/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -36,8 +36,12 @@
   expectFailure("[{[]:\"\"}]", "Incorrectly typed entry");
   expectFailure("[{}]", "Empty entry");
   expectFailure("[{\"directory\":\"\",\"command\":\"\"}]", "Missing file");
-  expectFailure("[{\"directory\":\"\",\"file\":\"\"}]", "Missing command");
+  expectFailure("[{\"directory\":\"\",\"file\":\"\"}]", "Missing command or arguments");
   expectFailure("[{\"command\":\"\",\"file\":\"\"}]", "Missing directory");
+  expectFailure("[{\"directory\":\"\",\"arguments\":[]}]", "Missing file");
+  expectFailure("[{\"arguments\":\"\",\"file\":\"\"}]", "Missing directory");
+  expectFailure("[{\"directory\":\"\",\"arguments\":\"\",\"file\":\"\"}]", "Arguments not array");
+  expectFailure("[{\"directory\":\"\",\"command\":[],\"file\":\"\"}]", "Command not string");
 }
 
 static std::vector getAllFiles(StringRef JSONDatabase,
@@ -126,6 +130,25 @@
   return Commands[0];
 }
 
+TEST(JSONCompilationDatabase, ArgumentsPreferredOverCommand) {
+   StringRef Directory("//net/dir");
+   StringRef FileName("//net/dir/filename");
+   StringRef Command("command");
+   StringRef Arguments = "arguments";
+   Twine ArgumentsAccumulate;
+   std::string ErrorMessage;
+   CompileCommand FoundCommand = findCompileArgsInJsonDatabase(
+  FileName,
+  ("[{\"directory\":\"" + Directory + "\","
+ "\"command\":\"" + Command + "\","
+ "\"arguments\":[\"" + Arguments + "\"],"
+ "\"file\":\"" + FileName + "\"}]").str(),
+  ErrorMessage);
+   EXPECT_EQ(Directory, FoundCommand.Directory) << ErrorMessage;
+   EXPECT_EQ(1u, FoundCommand.CommandLine.size()) << ErrorMessage;
+   EXPECT_EQ(Arguments, FoundCommand.CommandLine[0]) << ErrorMessage;
+}
+
 struct FakeComparator : public PathComparator {
   ~FakeComparator() override {}
   bool equivalent(StringRef FileA, StringRef FileB) const override {
Index: ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ ../llvm/tools/clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -221,9 +221,8 @@
 SmallString<8> DirectoryStorage;
 SmallString<1024> CommandStorage;
 Commands.emplace_back(
-// FIXME: Escape correctly:
-CommandsRef[I].first->getValue(DirectoryStorage),
-unescapeCommandLine(CommandsRef[I].second->getValue(CommandStorage)));
+  CommandsRef[I].first->getValue(DirectoryStorage),
+  CommandsRef[I].second);
   }
 }
 
@@ -243,43 +242,59 @@
 ErrorMessage = "Expected array.";
 return false;
   }
-  for (llvm::yaml::SequenceNode::iterator AI = Array->begin(),
-  AE = Array->end();
-   AI != AE; ++AI) {
-llvm::yaml::MappingNode *Object = dyn_cast(&*AI);
+  for (auto& NextObject : *Array) {
+llvm::yaml::MappingNode *Object = dyn_cast(&NextObject);
 if (!Object) {
   ErrorMessage = "Expected object.";
   return false;
 }
 llvm::yaml::ScalarNode *Directory = nullptr;
-llvm::yaml::ScalarNode *Command = nullptr;
+std::vector Arguments;
+std::vector Command;
 llvm::yaml::ScalarNode *File = nullptr;
-for (llvm::yaml::MappingNode::iterator KVI = Object->begin(),
-   KVE = Object->end();
- KVI != KVE; ++KVI) {
-  llvm::yaml::Node *Value = (*KVI).getValue();
+bool ArgumentsFound = false;
+bool CommandFound = false;
+for (auto& NextKeyValue : *Object) {
+  llvm::yaml::ScalarNode *KeyString =
+  dyn_cast(NextKeyValue.getKey());
+  if (!KeyString) {
+ErrorMessage = "Expected strings as key.";
+return false;
+  }
+  SmallString<10> KeyStorage;
+  StringRef KeyValue = KeyString->getValue(KeyStorage);
+  llvm::yaml::Node *Value = NextKeyValue.getValue();
   if (!Value) {
 ErrorMessage = "Expected value.";
 return false;
   }
   llvm::yaml::ScalarNode *ValueString =
   dyn_cast(Value);
-  if (!ValueString) {
-ErrorMessage = "Expected string as value.";
+  llvm::yaml::SequenceNode *SequenceString =
+  dyn_cast(Value);
+  if (KeyValue == "arguments" && !Seq

r244974 - Wdeprecated: RegionBindingsRef are copy constructed, make sure that's safe by removing the unnecessary user-declared copy assignment operator

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 17:33:24 2015
New Revision: 244974

URL: http://llvm.org/viewvc/llvm-project?rev=244974&view=rev
Log:
Wdeprecated: RegionBindingsRef are copy constructed, make sure that's safe by 
removing the unnecessary user-declared copy assignment operator

The user-defined copy assignment looks like it was working around the
presence of a reference member (that probably doesn't change in the copy
assignment cases present in the program). Rather than continuing this - just
change the reference to a pointer and let all the special members be
defined implicitly.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=244974&r1=244973&r2=244974&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Thu Aug 13 17:33:24 2015
@@ -149,7 +149,8 @@ typedef llvm::ImmutableMap {
- ClusterBindings::Factory &CBFactory;
+  ClusterBindings::Factory *CBFactory;
+
 public:
   typedef llvm::ImmutableMapRef
   ParentTy;
@@ -157,21 +158,21 @@ public:
   RegionBindingsRef(ClusterBindings::Factory &CBFactory,
 const RegionBindings::TreeTy *T,
 RegionBindings::TreeTy::Factory *F)
-: llvm::ImmutableMapRef(T, F),
-  CBFactory(CBFactory) {}
+  : llvm::ImmutableMapRef(T, F),
+CBFactory(&CBFactory) {}
 
   RegionBindingsRef(const ParentTy &P, ClusterBindings::Factory &CBFactory)
-: llvm::ImmutableMapRef(P),
-  CBFactory(CBFactory) {}
+  : llvm::ImmutableMapRef(P),
+CBFactory(&CBFactory) {}
 
   RegionBindingsRef add(key_type_ref K, data_type_ref D) const {
-return RegionBindingsRef(static_cast(this)->add(K, D),
- CBFactory);
+return RegionBindingsRef(static_cast(this)->add(K, D),
+ *CBFactory);
   }
 
   RegionBindingsRef remove(key_type_ref K) const {
-return RegionBindingsRef(static_cast(this)->remove(K),
- CBFactory);
+return RegionBindingsRef(static_cast(this)->remove(K),
+ *CBFactory);
   }
 
   RegionBindingsRef addBinding(BindingKey K, SVal V) const;
@@ -179,16 +180,9 @@ public:
   RegionBindingsRef addBinding(const MemRegion *R,
BindingKey::Kind k, SVal V) const;
 
-  RegionBindingsRef &operator=(const RegionBindingsRef &X) {
-*static_cast(this) = X;
-return *this;
-  }
-
   const SVal *lookup(BindingKey K) const;
   const SVal *lookup(const MemRegion *R, BindingKey::Kind k) const;
-  const ClusterBindings *lookup(const MemRegion *R) const {
-return static_cast(this)->lookup(R);
-  }
+  using llvm::ImmutableMapRef::lookup;
 
   RegionBindingsRef removeBinding(BindingKey K);
 
@@ -245,10 +239,10 @@ RegionBindingsRef RegionBindingsRef::add
   const MemRegion *Base = K.getBaseRegion();
 
   const ClusterBindings *ExistingCluster = lookup(Base);
-  ClusterBindings Cluster = (ExistingCluster ? *ExistingCluster
- : CBFactory.getEmptyMap());
+  ClusterBindings Cluster =
+  (ExistingCluster ? *ExistingCluster : CBFactory->getEmptyMap());
 
-  ClusterBindings NewCluster = CBFactory.add(Cluster, K, V);
+  ClusterBindings NewCluster = CBFactory->add(Cluster, K, V);
   return add(Base, NewCluster);
 }
 
@@ -277,7 +271,7 @@ RegionBindingsRef RegionBindingsRef::rem
   if (!Cluster)
 return *this;
 
-  ClusterBindings NewCluster = CBFactory.remove(*Cluster, K);
+  ClusterBindings NewCluster = CBFactory->remove(*Cluster, K);
   if (NewCluster.isEmpty())
 return remove(Base);
   return add(Base, NewCluster);


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


Re: [PATCH] D11629: APValues and Constants and MaterializedTemporaryExpr need to have stable maps

2015-08-13 Thread David Majnemer via cfe-commits
majnemer updated this revision to Diff 32100.
majnemer added a comment.

- Address Justin's review comments.
- Address Richard's review comments.


http://reviews.llvm.org/D11629

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/PR24289.cpp

Index: test/CodeGenCXX/PR24289.cpp
===
--- /dev/null
+++ test/CodeGenCXX/PR24289.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu -std=c++11 | FileCheck %s
+
+namespace std {
+template 
+struct initializer_list {
+  const T *Begin;
+  __SIZE_TYPE__ Size;
+
+  constexpr initializer_list(const T *B, __SIZE_TYPE__ S)
+  : Begin(B), Size(S) {}
+};
+}
+
+void f() {
+  static std::initializer_list> a{
+  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
+  static std::initializer_list> b{
+  {0}, {0}, {0}, {0}};
+  static std::initializer_list> c{
+  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
+  static std::initializer_list> d{
+  {0}, {0}, {0}, {0}, {0}};
+  static std::initializer_list> e{
+  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
+}
+
+// CHECK-DAG: @_ZZ1fvE1a = internal global %{{.*}} { %{{.*}}* getelementptr inbounds ([14 x %{{.*}}], [14 x %{{.*}}]
+// CHECK-DAG: * @_ZGRZ1fvE1a_, i32 0, i32 0), i64 14 }
+// CHECK-DAG: @_ZGRZ1fvE1a0_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a1_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a2_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a3_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a4_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a5_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a6_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a7_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a8_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a9_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1aA_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1aB_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1aC_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1aD_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a_ = internal constant [14 x %{{.*}}] [%{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a0_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a1_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a2_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a3_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a4_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a5_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a6_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a7_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a8_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a9_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aA_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aB_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aC_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aD_, i32 0, i32 0), i64 1 }]
+// CHECK-DAG: @_ZZ1fvE1b = internal global %{{.*}} { %{{.*}}* getelementptr inbounds ([4 x %{{.*}}], [4 x %{{.*}}]*
+// CHECK-DAG: @_ZGRZ1fvE1b_, i32 0, i32 0), i64 4 }
+// CHECK-DAG: @_ZGRZ1fvE1b0_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1b1_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1b2_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1b3_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1b_ = internal constant [4 x %{{.*}}] [%{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1b0_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1b1_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1b2_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1b3_, i32 0, i32 0), i64 1 }]
+// CHECK-DAG: @_ZZ1fvE1c = internal global %{{.*}} { %{{.*}}* getelementptr inbounds ([9 x %{{.*}}], [9 x %{{.*}}]*
+// CHE

r244975 - Wdeprecated: CollectReachableSymbolsCallback are move constructed/returned by value, so make sure they're copy/moveable

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 17:50:09 2015
New Revision: 244975

URL: http://llvm.org/viewvc/llvm-project?rev=244975&view=rev
Log:
Wdeprecated: CollectReachableSymbolsCallback are move constructed/returned by 
value, so make sure they're copy/moveable

(return by value is in ExprEngine::processPointerEscapedOnBind and any
other call to the scanReachableSymbols function template used there)

Protect the special members in the base class to avoid slicing, and make
derived classes final so these special members don't accidentally become
public on an intermediate base which would open up the possibility of
slicing again.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h?rev=244975&r1=244974&r2=244975&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
Thu Aug 13 17:50:09 2015
@@ -650,6 +650,12 @@ private:
 };
 
 class SymbolVisitor {
+protected:
+  SymbolVisitor() = default;
+  SymbolVisitor(const SymbolVisitor &) = default;
+  SymbolVisitor(SymbolVisitor &&) {}
+  ~SymbolVisitor() = default;
+
 public:
   /// \brief A visitor method invoked by 
ProgramStateManager::scanReachableSymbols.
   ///
@@ -657,7 +663,6 @@ public:
   /// false otherwise.
   virtual bool VisitSymbol(SymbolRef sym) = 0;
   virtual bool VisitMemRegion(const MemRegion *region) { return true; }
-  virtual ~SymbolVisitor();
 };
 
 } // end GR namespace

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=244975&r1=244974&r2=244975&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Thu Aug 13 17:50:09 
2015
@@ -515,7 +515,7 @@ REGISTER_MAP_WITH_PROGRAMSTATE(ReallocPa
 REGISTER_MAP_WITH_PROGRAMSTATE(FreeReturnValue, SymbolRef, SymbolRef)
 
 namespace {
-class StopTrackingCallback : public SymbolVisitor {
+class StopTrackingCallback final : public SymbolVisitor {
   ProgramStateRef state;
 public:
   StopTrackingCallback(ProgramStateRef st) : state(st) {}

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=244975&r1=244974&r2=244975&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Thu Aug 13 
17:50:09 2015
@@ -2678,7 +2678,7 @@ public:
 } // end anonymous namespace
 
 namespace {
-class StopTrackingCallback : public SymbolVisitor {
+class StopTrackingCallback final : public SymbolVisitor {
   ProgramStateRef state;
 public:
   StopTrackingCallback(ProgramStateRef st) : state(st) {}

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp?rev=244975&r1=244974&r2=244975&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp Thu Aug 13 
17:50:09 2015
@@ -92,7 +92,7 @@ public:
 REGISTER_MAP_WITH_PROGRAMSTATE(StreamMap, SymbolRef, StreamState)
 
 namespace {
-class StopTrackingCallback : public SymbolVisitor {
+class StopTrackingCallback final : public SymbolVisitor {
   ProgramStateRef state;
 public:
   StopTrackingCallback(ProgramStateRef st) : state(st) {}

Modified: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp?rev=244975&r1=244974&r2=244975&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp Thu Aug 13 17:50:09 2015
@@ -120,7 +120,7 @@ Environment EnvironmentManager::bindExpr
 }
 
 namespace {
-class MarkLiveCallback : public SymbolV

Re: [PATCH] D11572: [Static Analyzer] Checker for OS X / iOS localizability issues

2015-08-13 Thread Kulpreet Chilana via cfe-commits
kulpreet updated this revision to Diff 32102.
kulpreet added a comment.

Fixed memory corruption bug with temporary std::string - found with address 
sanitizer.

Now, all regression tests pass with MallocScribble on.


http://reviews.llvm.org/D11572

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  test/Analysis/localization-aggressive.m
  test/Analysis/localization.m

Index: test/Analysis/localization.m
===
--- /dev/null
+++ test/Analysis/localization.m
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region -analyzer-checker=alpha.osx.cocoa.NonLocalizedStringChecker -analyzer-checker=alpha.osx.cocoa.EmptyLocalizationContextChecker -verify  %s
+
+// The larger set of tests in located in localization.m. These are tests
+// specific for non-aggressive reporting.
+
+// These declarations were reduced using Delta-Debugging from Foundation.h
+// on Mac OS X.
+
+#define nil ((id)0)
+#define NSLocalizedString(key, comment)\
+  [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
+#define NSLocalizedStringFromTable(key, tbl, comment)  \
+  [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:(tbl)]
+#define NSLocalizedStringFromTableInBundle(key, tbl, bundle, comment)  \
+  [bundle localizedStringForKey:(key) value:@"" table:(tbl)]
+#define NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment)  \
+  [bundle localizedStringForKey:(key) value:(val) table:(tbl)]
+@interface NSObject
++ (id)alloc;
+- (id)init;
+@end
+@interface NSString : NSObject
+@end
+@interface NSBundle : NSObject
++ (NSBundle *)mainBundle;
+- (NSString *)localizedStringForKey:(NSString *)key
+  value:(NSString *)value
+  table:(NSString *)tableName;
+@end
+@interface UILabel : NSObject
+@property(nullable, nonatomic, copy) NSString *text;
+@end
+@interface TestObject : NSObject
+@property(strong) NSString *text;
+@end
+
+@interface LocalizationTestSuite : NSObject
+int random();
+@end
+
+// Test cases begin here
+@implementation LocalizationTestSuite
+
+// An object passed in as an parameter's string member
+// should not be considered unlocalized
+- (void)testObjectAsArgument:(TestObject *)argumentObject {
+  UILabel *testLabel = [[UILabel alloc] init];
+
+  [testLabel setText:[argumentObject text]]; // no-warning
+  [testLabel setText:argumentObject.text];   // no-warning
+}
+
+- (void)testLocalizationErrorDetectedOnPathway {
+  UILabel *testLabel = [[UILabel alloc] init];
+  NSString *bar = NSLocalizedString(@"Hello", @"Comment");
+
+  if (random()) {
+bar = @"Unlocalized string";
+  }
+
+  [testLabel setText:bar]; // expected-warning {{String should be localized}}
+}
+
+- (void)testOneCharacterStringsDoNotGiveAWarning {
+  UILabel *testLabel = [[UILabel alloc] init];
+  NSString *bar = NSLocalizedString(@"Hello", @"Comment");
+
+  if (random()) {
+bar = @"-";
+  }
+
+  [testLabel setText:bar]; // no-warning
+}
+
+- (void)testOneCharacterUTFStringsDoNotGiveAWarning {
+  UILabel *testLabel = [[UILabel alloc] init];
+  NSString *bar = NSLocalizedString(@"Hello", @"Comment");
+
+  if (random()) {
+bar = @"\u2014";
+  }
+
+  [testLabel setText:bar]; // no-warning
+}
+
+@end
Index: test/Analysis/localization-aggressive.m
===
--- /dev/null
+++ test/Analysis/localization-aggressive.m
@@ -0,0 +1,243 @@
+// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region  -analyzer-checker=alpha.osx.cocoa.NonLocalizedStringChecker -analyzer-checker=alpha.osx.cocoa.EmptyLocalizationContextChecker -verify  -analyzer-config AggressiveReport=true %s
+
+// These declarations were reduced using Delta-Debugging from Foundation.h
+// on Mac OS X.
+
+#define nil ((id)0)
+#define NSLocalizedString(key, comment)\
+  [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]
+#define NSLocalizedStringFromTable(key, tbl, comment)  \
+  [[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:(tbl)]
+#define NSLocalizedStringFromTableInBundle(key, tbl, bundle, comment)  \
+  [bundle localizedStringForKey:(key) value:@"" table:(tbl)]
+#define NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment)  \
+  [bundle localizedStringForKey:(key) value:(val) table:(tbl)]
+#define CGFLOAT_TYPE double
+typedef CGFLOAT_TYPE CGFloat;
+struct CGPoint {
+  CGFloat x;
+  CGFloat y;
+};
+typedef struct CGPoint CGPoint;
+@interface NSObject
++ (id)alloc;
+- (id)init;
+@end
+@class NSDictionary;
+@interface NSString : NSObject
+- (void)drawAtPoint:(CGPoint)point withAttributes:(NSDictionary *)attrs;
++ (instancetype)localizedStringWithFormat:(NSString *

Re: [PATCH] D11629: APValues and Constants and MaterializedTemporaryExpr need to have stable maps

2015-08-13 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ASTContext.cpp:8557
@@ +8556,3 @@
+  if (MayCreate) {
+auto *MTVI = &MaterializedTemporaryValues[E];
+if (*MTVI == nullptr) {

Maybe use a reference here rather than a pointer.


Comment at: lib/AST/ASTContext.cpp:8559-8560
@@ +8558,4 @@
+if (*MTVI == nullptr) {
+  *MTVI = BumpAlloc.Allocate();
+  new (*MTVI) APValue();
+}

More succinctly expressed as:

MTVI = new (*this) APValue;


Comment at: lib/AST/ASTContext.cpp:8565-8566
@@ -8558,5 +8564,4 @@
 
-  llvm::DenseMap::iterator I =
-  MaterializedTemporaryValues.find(E);
-  return I == MaterializedTemporaryValues.end() ? nullptr : &I->second;
+  auto I = MaterializedTemporaryValues.find(E);
+  return I == MaterializedTemporaryValues.end() ? nullptr : I->second;
 }

This is now just `MaterializedTemporaryValues.lookup(E)`


Comment at: lib/CodeGen/CodeGenModule.h:377
@@ -376,3 +376,3 @@
   llvm::DenseMap StaticLocalDeclGuardMap;
-  llvm::DenseMap MaterializedGlobalTemporaryMap;
+  std::map MaterializedGlobalTemporaryMap;
 

Can you fix this instead by not holding onto `Slot` in 
`CodeGenModule::GetAddrOfGlobalTemporary`? (Do the map lookup again at the end 
of the function.) Twice as many `DenseMap` lookups seems likely to be cheaper 
than switching to a `std::map`.


http://reviews.llvm.org/D11629



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


r244979 - Wdeprecated: BugReporterVisitors are copied for cloning (BugReporterVisitorImpl), make sure such copies are safe

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 17:58:37 2015
New Revision: 244979

URL: http://llvm.org/viewvc/llvm-project?rev=244979&view=rev
Log:
Wdeprecated: BugReporterVisitors are copied for cloning 
(BugReporterVisitorImpl), make sure such copies are safe

Make the copy/move ctors defaulted in the base class and make the
derived classes final to avoid any intermediate hierarchy slicing if
these types were further derived.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=244979&r1=244978&r2=244979&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
Thu Aug 13 17:58:37 2015
@@ -37,6 +37,9 @@ class PathDiagnosticPiece;
 /// will have to provide your own implementation.)
 class BugReporterVisitor : public llvm::FoldingSetNode {
 public:
+  BugReporterVisitor() = default;
+  BugReporterVisitor(const BugReporterVisitor &) = default;
+  BugReporterVisitor(BugReporterVisitor &&) = default;
   virtual ~BugReporterVisitor();
 
   /// \brief Returns a copy of this BugReporter.
@@ -92,9 +95,8 @@ class BugReporterVisitorImpl : public Bu
   }
 };
 
-class FindLastStoreBRVisitor
-  : public BugReporterVisitorImpl
-{
+class FindLastStoreBRVisitor final
+: public BugReporterVisitorImpl {
   const MemRegion *R;
   SVal V;
   bool Satisfied;
@@ -124,9 +126,8 @@ public:
  BugReport &BR) override;
 };
 
-class TrackConstraintBRVisitor
-  : public BugReporterVisitorImpl
-{
+class TrackConstraintBRVisitor final
+: public BugReporterVisitorImpl {
   DefinedSVal Constraint;
   bool Assumption;
   bool IsSatisfied;
@@ -161,8 +162,8 @@ private:
 
 /// \class NilReceiverBRVisitor
 /// \brief Prints path notes when a message is sent to a nil receiver.
-class NilReceiverBRVisitor
-  : public BugReporterVisitorImpl {
+class NilReceiverBRVisitor final
+: public BugReporterVisitorImpl {
 public:
 
   void Profile(llvm::FoldingSetNodeID &ID) const override {
@@ -181,7 +182,8 @@ public:
 };
 
 /// Visitor that tries to report interesting diagnostics from conditions.
-class ConditionBRVisitor : public BugReporterVisitorImpl {
+class ConditionBRVisitor final
+: public BugReporterVisitorImpl {
 public:
   void Profile(llvm::FoldingSetNodeID &ID) const override {
 static int x = 0;
@@ -247,8 +249,8 @@ public:
 /// \brief Suppress reports that might lead to known false positives.
 ///
 /// Currently this suppresses reports based on locations of bugs.
-class LikelyFalsePositiveSuppressionBRVisitor
-  : public BugReporterVisitorImpl {
+class LikelyFalsePositiveSuppressionBRVisitor final
+: public BugReporterVisitorImpl {
 public:
   static void *getTag() {
 static int Tag = 0;
@@ -276,8 +278,8 @@ public:
 ///
 /// As a result, BugReporter will not prune the path through the function even
 /// if the region's contents are not modified/accessed by the call.
-class UndefOrNullArgVisitor
-  : public BugReporterVisitorImpl {
+class UndefOrNullArgVisitor final
+: public BugReporterVisitorImpl {
 
   /// The interesting memory region this visitor is tracking.
   const MemRegion *R;
@@ -297,9 +299,8 @@ public:
  BugReport &BR) override;
 };
 
-class SuppressInlineDefensiveChecksVisitor
-: public BugReporterVisitorImpl
-{
+class SuppressInlineDefensiveChecksVisitor final
+: public BugReporterVisitorImpl {
   /// The symbolic value for which we are tracking constraints.
   /// This value is constrained to null in the end of path.
   DefinedSVal V;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp?rev=244979&r1=244978&r2=244979&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Thu Aug 13 17:58:37 
2015
@@ -392,7 +392,8 @@ private:
   /// The bug visitor which allows us to print extra diagnostics along the
   /// BugReport path. For example, showing the allocation site of the leaked
   /// region.
-  class MallocBugVisitor : public BugReporterVisitorImpl {
+  class MallocBugVisitor final
+  : public BugReporterVisitorImpl {
   protected:
 enum NotificationMode {
   Normal,
@@ -414,8 +415,6 @@ private:
 MallocBugVisitor(SymbolRef S, bool isLeak = false)
: Sym(S), Mode(Normal), FailedReallocSymbol(nullptr), IsLeak(isLeak) {}
 
-~MallocBugVisit

r244978 - Follow up r244975: The ctors of an abstract class don't need to be protected - the object isn't directly constructible/doesn't present a slicing risk

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 17:58:35 2015
New Revision: 244978

URL: http://llvm.org/viewvc/llvm-project?rev=244978&view=rev
Log:
Follow up r244975: The ctors of an abstract class don't need to be protected - 
the object isn't directly constructible/doesn't present a slicing risk

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h?rev=244978&r1=244977&r2=244978&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
Thu Aug 13 17:58:35 2015
@@ -651,12 +651,13 @@ private:
 
 class SymbolVisitor {
 protected:
+  ~SymbolVisitor() = default;
+
+public:
   SymbolVisitor() = default;
   SymbolVisitor(const SymbolVisitor &) = default;
   SymbolVisitor(SymbolVisitor &&) {}
-  ~SymbolVisitor() = default;
 
-public:
   /// \brief A visitor method invoked by 
ProgramStateManager::scanReachableSymbols.
   ///
   /// The method returns \c true if symbols should continue be scanned and \c


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


r244980 - Fix the MSVC build which cannot manifest default move ops

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 18:05:58 2015
New Revision: 244980

URL: http://llvm.org/viewvc/llvm-project?rev=244980&view=rev
Log:
Fix the MSVC build which cannot manifest default move ops

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=244980&r1=244979&r2=244980&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
Thu Aug 13 18:05:58 2015
@@ -39,7 +39,7 @@ class BugReporterVisitor : public llvm::
 public:
   BugReporterVisitor() = default;
   BugReporterVisitor(const BugReporterVisitor &) = default;
-  BugReporterVisitor(BugReporterVisitor &&) = default;
+  BugReporterVisitor(BugReporterVisitor &&) {}
   virtual ~BugReporterVisitor();
 
   /// \brief Returns a copy of this BugReporter.


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


Re: r244867 - Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.

2015-08-13 Thread NAKAMURA Takumi via cfe-commits
Tweaked a test in r244970.
Could you split it out if you would like to run it for the default target?
On Fri, Aug 14, 2015 at 5:07 AM Ivan Krasin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Thank you, Yaron. Understood.
>
> On Thu, Aug 13, 2015 at 11:04 AM, Yaron Keren 
> wrote:
>
>> There is great variety of OSs, compilers, configs in the bots. You can't
>> get the smae with try bots unless everything is duplicated which is a
>> waste. You test locally, commit, watch the bots here:
>>
>>  http://lab.llvm.org:8011/grid
>>
>> or wait for buildbot failure e-mails which arrive a bit slower.
>> Breaks may happen even if you test locally, so it's critical be around
>> after the commit to to resolve such issues.
>>
>>  http://llvm.org/docs/DeveloperPolicy.html#quality
>>
>>
>>
>> 2015-08-13 20:51 GMT+03:00 Ivan Krasin :
>>
>>> Thank you, Yaron.
>>>
>>> Sorry for breaking the build, it obviously passed locally and I didn't
>>> think about all the variety of the supported configs. :(
>>>
>>> Does LLVM have try bots, so that I can run the tests with my patch
>>> before committing it?
>>>
>>> krasin
>>>
>>
>> On Thu, Aug 13, 2015 at 3:40 AM, Renato Golin 
>> wrote:
>>
>>> On 13 August 2015 at 07:15, Yaron Keren via cfe-commits
>>>  wrote:
>>> > CHECK-EIGHT is failing bots, see
>>> >
>>> >
>>> http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24306/steps/check-all/logs/FAIL%3A%20Clang%3A%3Adependency-gen.c
>>>
>>>
>>> That check only works if compiler-rt is built in, and supports the
>>> target. I wouldn't put that in a Clang test.
>>>
>>
>>
> ___
> 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


r244981 - Wdeprecated: Make the SecKeychainBugVisitor copyable (for the clone support in the CRTP base) my removing the user-declared dtor

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 18:09:18 2015
New Revision: 244981

URL: http://llvm.org/viewvc/llvm-project?rev=244981&view=rev
Log:
Wdeprecated: Make the SecKeychainBugVisitor copyable (for the clone support in 
the CRTP base) my removing the user-declared dtor

The implicit dtor is just as good, and avoid suppressing implicit
copy/move ops.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp?rev=244981&r1=244980&r2=244981&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp Thu Aug 
13 18:09:18 2015
@@ -136,7 +136,6 @@ private:
 
   public:
 SecKeychainBugVisitor(SymbolRef S) : Sym(S) {}
-~SecKeychainBugVisitor() override {}
 
 void Profile(llvm::FoldingSetNodeID &ID) const override {
   static int X = 0;


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


Re: r244867 - Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.

2015-08-13 Thread Ivan Krasin via cfe-commits
Hi there,

I will remove both test cases, which rely on the existence of the default
blacklist. It's handled by the driver anyway, and the code I changed is in
the frontend; at this point, there's no such a thing, as a default
blacklist, all of them are explicit.
Just a sec.

krasin

On Thu, Aug 13, 2015 at 4:09 PM, NAKAMURA Takumi 
wrote:

> Tweaked a test in r244970.
> Could you split it out if you would like to run it for the default target?
> On Fri, Aug 14, 2015 at 5:07 AM Ivan Krasin via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Thank you, Yaron. Understood.
>>
>> On Thu, Aug 13, 2015 at 11:04 AM, Yaron Keren 
>> wrote:
>>
>>> There is great variety of OSs, compilers, configs in the bots. You can't
>>> get the smae with try bots unless everything is duplicated which is a
>>> waste. You test locally, commit, watch the bots here:
>>>
>>>  http://lab.llvm.org:8011/grid
>>>
>>> or wait for buildbot failure e-mails which arrive a bit slower.
>>> Breaks may happen even if you test locally, so it's critical be around
>>> after the commit to to resolve such issues.
>>>
>>>  http://llvm.org/docs/DeveloperPolicy.html#quality
>>>
>>>
>>>
>>> 2015-08-13 20:51 GMT+03:00 Ivan Krasin :
>>>
 Thank you, Yaron.

 Sorry for breaking the build, it obviously passed locally and I didn't
 think about all the variety of the supported configs. :(

 Does LLVM have try bots, so that I can run the tests with my patch
 before committing it?

 krasin

>>>
>>> On Thu, Aug 13, 2015 at 3:40 AM, Renato Golin 
>>> wrote:
>>>
 On 13 August 2015 at 07:15, Yaron Keren via cfe-commits
  wrote:
 > CHECK-EIGHT is failing bots, see
 >
 >
 http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24306/steps/check-all/logs/FAIL%3A%20Clang%3A%3Adependency-gen.c


 That check only works if compiler-rt is built in, and supports the
 target. I wouldn't put that in a Clang test.

>>>
>>>
>> ___
>> 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


r244983 - Wdeprecated: Make Filter safely move constructible.

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 18:15:20 2015
New Revision: 244983

URL: http://llvm.org/viewvc/llvm-project?rev=244983&view=rev
Log:
Wdeprecated: Make Filter safely move constructible.

makeFilter returns Filters by value which seems to be only safe when the
copy doesn't occur and RVO kicks in. Make the object safely movable to
support this more reliably.

Modified:
cfe/trunk/include/clang/Sema/Lookup.h

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=244983&r1=244982&r2=244983&view=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Thu Aug 13 18:15:20 2015
@@ -575,6 +575,11 @@ public:
 {}
 
   public:
+Filter(Filter &&F)
+: Results(F.Results), I(F.I), Changed(F.Changed),
+  CalledDone(F.CalledDone) {
+  F.CalledDone = true;
+}
 ~Filter() {
   assert(CalledDone &&
  "LookupResult::Filter destroyed without done() call");


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


Re: [PATCH] D11629: APValues and Constants and MaterializedTemporaryExpr need to have stable maps

2015-08-13 Thread David Majnemer via cfe-commits
majnemer updated this revision to Diff 32106.
majnemer added a comment.

- Address Richard's latest review comments.


http://reviews.llvm.org/D11629

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCXX/PR24289.cpp

Index: test/CodeGenCXX/PR24289.cpp
===
--- /dev/null
+++ test/CodeGenCXX/PR24289.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu -std=c++11 | FileCheck %s
+
+namespace std {
+template 
+struct initializer_list {
+  const T *Begin;
+  __SIZE_TYPE__ Size;
+
+  constexpr initializer_list(const T *B, __SIZE_TYPE__ S)
+  : Begin(B), Size(S) {}
+};
+}
+
+void f() {
+  static std::initializer_list> a{
+  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
+  static std::initializer_list> b{
+  {0}, {0}, {0}, {0}};
+  static std::initializer_list> c{
+  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
+  static std::initializer_list> d{
+  {0}, {0}, {0}, {0}, {0}};
+  static std::initializer_list> e{
+  {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}};
+}
+
+// CHECK-DAG: @_ZZ1fvE1a = internal global %{{.*}} { %{{.*}}* getelementptr inbounds ([14 x %{{.*}}], [14 x %{{.*}}]
+// CHECK-DAG: * @_ZGRZ1fvE1a_, i32 0, i32 0), i64 14 }
+// CHECK-DAG: @_ZGRZ1fvE1a0_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a1_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a2_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a3_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a4_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a5_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a6_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a7_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a8_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a9_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1aA_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1aB_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1aC_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1aD_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1a_ = internal constant [14 x %{{.*}}] [%{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a0_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a1_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a2_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a3_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a4_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a5_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a6_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a7_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a8_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1a9_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aA_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aB_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aC_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1aD_, i32 0, i32 0), i64 1 }]
+// CHECK-DAG: @_ZZ1fvE1b = internal global %{{.*}} { %{{.*}}* getelementptr inbounds ([4 x %{{.*}}], [4 x %{{.*}}]*
+// CHECK-DAG: @_ZGRZ1fvE1b_, i32 0, i32 0), i64 4 }
+// CHECK-DAG: @_ZGRZ1fvE1b0_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1b1_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1b2_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1b3_ = internal constant [1 x i32] zeroinitializer
+// CHECK-DAG: @_ZGRZ1fvE1b_ = internal constant [4 x %{{.*}}] [%{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1b0_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1b1_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1b2_, i32 0, i32 0), i64 1 }, %{{.*}} { i32* getelementptr inbounds ([1 x i32], [1 x i32]* @_ZGRZ1fvE1b3_, i32 0, i32 0), i64 1 }]
+// CHECK-DAG: @_ZZ1fvE1c = internal global %{{.*}} { %{{.*}}* getelementptr inbounds ([9 x %{{.*}}], [9 x %{{.*}}]*
+// CHECK-DAG: @_ZGRZ1fvE1c_, i32 

[PATCH] D12021: Remove test cases, which rely on the default sanitizer blacklists.The default blacklists may vary across different architectures andconfigurations. It was not wise to include into http

2015-08-13 Thread Ivan Krasin via cfe-commits
krasin created this revision.
krasin added a reviewer: chapuni.
krasin added subscribers: pcc, cfe-commits.

http://reviews.llvm.org/D12021

Files:
  test/Frontend/dependency-gen.c

Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -24,11 +24,6 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
-// RUN: %clang -target x86_64-linux-gnu -MD -MF - %s -fsyntax-only 
-fsanitize=address -flto -I . | FileCheck -check-prefix=CHECK-EIGHT %s
-// CHECK-EIGHT: {{ }}x.h
-// RUN: %clang -target x86_64-linux-gnu -MD -MF - %s -fsyntax-only 
-fsanitize=address -flto -I . -fno-sanitize-blacklist | FileCheck 
-check-prefix=CHECK-NINE %s
-// CHECK-NINE-NOT: asan_blacklist.txt
-// CHECK-NINE: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
 #include 
 #endif


Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -24,11 +24,6 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto -fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
-// RUN: %clang -target x86_64-linux-gnu -MD -MF - %s -fsyntax-only -fsanitize=address -flto -I . | FileCheck -check-prefix=CHECK-EIGHT %s
-// CHECK-EIGHT: {{ }}x.h
-// RUN: %clang -target x86_64-linux-gnu -MD -MF - %s -fsyntax-only -fsanitize=address -flto -I . -fno-sanitize-blacklist | FileCheck -check-prefix=CHECK-NINE %s
-// CHECK-NINE-NOT: asan_blacklist.txt
-// CHECK-NINE: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
 #include 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r244867 - Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.

2015-08-13 Thread Ivan Krasin via cfe-commits
I have created http://reviews.llvm.org/D12021, please take a look.

On Thu, Aug 13, 2015 at 4:13 PM, Ivan Krasin  wrote:

> Hi there,
>
> I will remove both test cases, which rely on the existence of the default
> blacklist. It's handled by the driver anyway, and the code I changed is in
> the frontend; at this point, there's no such a thing, as a default
> blacklist, all of them are explicit.
> Just a sec.
>
> krasin
>
> On Thu, Aug 13, 2015 at 4:09 PM, NAKAMURA Takumi 
> wrote:
>
>> Tweaked a test in r244970.
>> Could you split it out if you would like to run it for the default target?
>> On Fri, Aug 14, 2015 at 5:07 AM Ivan Krasin via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Thank you, Yaron. Understood.
>>>
>>> On Thu, Aug 13, 2015 at 11:04 AM, Yaron Keren 
>>> wrote:
>>>
 There is great variety of OSs, compilers, configs in the bots. You
 can't get the smae with try bots unless everything is duplicated which is a
 waste. You test locally, commit, watch the bots here:

  http://lab.llvm.org:8011/grid

 or wait for buildbot failure e-mails which arrive a bit slower.
 Breaks may happen even if you test locally, so it's critical be around
 after the commit to to resolve such issues.

  http://llvm.org/docs/DeveloperPolicy.html#quality



 2015-08-13 20:51 GMT+03:00 Ivan Krasin :

> Thank you, Yaron.
>
> Sorry for breaking the build, it obviously passed locally and I didn't
> think about all the variety of the supported configs. :(
>
> Does LLVM have try bots, so that I can run the tests with my patch
> before committing it?
>
> krasin
>

 On Thu, Aug 13, 2015 at 3:40 AM, Renato Golin 
 wrote:

> On 13 August 2015 at 07:15, Yaron Keren via cfe-commits
>  wrote:
> > CHECK-EIGHT is failing bots, see
> >
> >
> http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/24306/steps/check-all/logs/FAIL%3A%20Clang%3A%3Adependency-gen.c
>
>
> That check only works if compiler-rt is built in, and supports the
> target. I wouldn't put that in a Clang test.
>


>>> ___
>>> 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] D11629: APValues and Constants and MaterializedTemporaryExpr need to have stable maps

2015-08-13 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D11629



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


Re: [PATCH] D12021: Remove test cases, which rely on the default sanitizer blacklists.

2015-08-13 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

You could create a fake resource directory which contains only the 
`asan_blacklist.txt` file. See `test/Driver/Inputs/resource_dir` for an example 
of this kind of thing.


http://reviews.llvm.org/D12021



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


Re: [PATCH] D12021: Remove test cases, which rely on the default sanitizer blacklists.

2015-08-13 Thread Ivan Krasin via cfe-commits
krasin added a comment.

In http://reviews.llvm.org/D12021#224102, @pcc wrote:

> You could create a fake resource directory which contains only the 
> `asan_blacklist.txt` file. See `test/Driver/Inputs/resource_dir` for an 
> example of this kind of thing.


I believe it's unnecessary. The default blacklists are handled in 
https://github.com/llvm-mirror/clang/blob/82a8792ad361e9443615fc81ee8dd37c76e64dbd/lib/Driver/SanitizerArgs.cpp#L82,
 and the code I added is in the frontend. The tests I am removing are not 
really testing that blacklists get into the deps. They test that default 
blacklists are explicitly passed from the toolchain to the frontend. If there's 
no such a test, I could add it in a separate CL.


http://reviews.llvm.org/D12021



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


Re: [PATCH] D12021: Remove test cases, which rely on the default sanitizer blacklists.

2015-08-13 Thread Peter Collingbourne via cfe-commits
pcc accepted this revision.
pcc added a reviewer: pcc.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM

Yes, this can be a separate driver test.


http://reviews.llvm.org/D12021



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


r244985 - Remove test cases, which rely on the default sanitizer blacklists.

2015-08-13 Thread Ivan Krasin via cfe-commits
Author: krasin
Date: Thu Aug 13 18:37:28 2015
New Revision: 244985

URL: http://llvm.org/viewvc/llvm-project?rev=244985&view=rev
Log:
Remove test cases, which rely on the default sanitizer blacklists.

Summary:
The default blacklists may vary across different architectures and
configurations. It was not wise to include into http://reviews.llvm.org/D11968

Reviewers: chapuni, pcc

Subscribers: cfe-commits, pcc

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

Modified:
cfe/trunk/test/Frontend/dependency-gen.c

Modified: cfe/trunk/test/Frontend/dependency-gen.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/dependency-gen.c?rev=244985&r1=244984&r2=244985&view=diff
==
--- cfe/trunk/test/Frontend/dependency-gen.c (original)
+++ cfe/trunk/test/Frontend/dependency-gen.c Thu Aug 13 18:37:28 2015
@@ -24,11 +24,6 @@
 // RUN: %clang -MD -MF - %s -fsyntax-only -fsanitize=cfi-vcall -flto 
-fsanitize-blacklist=%t.blacklist -I ./ | FileCheck -check-prefix=CHECK-SEVEN %s
 // CHECK-SEVEN: .blacklist
 // CHECK-SEVEN: {{ }}x.h
-// RUN: %clang -target x86_64-linux-gnu -MD -MF - %s -fsyntax-only 
-fsanitize=address -flto -I . | FileCheck -check-prefix=CHECK-EIGHT %s
-// CHECK-EIGHT: {{ }}x.h
-// RUN: %clang -target x86_64-linux-gnu -MD -MF - %s -fsyntax-only 
-fsanitize=address -flto -I . -fno-sanitize-blacklist | FileCheck 
-check-prefix=CHECK-NINE %s
-// CHECK-NINE-NOT: asan_blacklist.txt
-// CHECK-NINE: {{ }}x.h
 #ifndef INCLUDE_FLAG_TEST
 #include 
 #endif


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


r244986 - Wdeprecated: Ensure CheckNames are copy assignable (used in setCurrentCheckName) by removing the unnecessary copy ctor

2015-08-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Thu Aug 13 18:38:46 2015
New Revision: 244986

URL: http://llvm.org/viewvc/llvm-project?rev=244986&view=rev
Log:
Wdeprecated: Ensure CheckNames are copy assignable (used in 
setCurrentCheckName) by removing the unnecessary copy ctor

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=244986&r1=244985&r2=244986&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h Thu Aug 13 
18:38:46 2015
@@ -89,8 +89,7 @@ class CheckName {
   explicit CheckName(StringRef Name) : Name(Name) {}
 
 public:
-  CheckName() {}
-  CheckName(const CheckName &Other) : Name(Other.Name) {}
+  CheckName() = default;
   StringRef getName() const { return Name; }
 };
 


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


  1   2   >