]> granicus.if.org Git - clang/log
clang
10 years agoSimplify the code a bit, NFC.
Rafael Espindola [Mon, 15 Sep 2014 19:24:44 +0000 (19:24 +0000)]
Simplify the code a bit, NFC.

hasConstructorVariants is always true for MS and false for Itanium.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217809 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMove emitCXXStructor to CGCXXABI.
Rafael Espindola [Mon, 15 Sep 2014 19:20:10 +0000 (19:20 +0000)]
Move emitCXXStructor to CGCXXABI.

A followup patch will address the code duplication.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217807 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoCreate a emitCXXStructor function and make the existing emitCXXConstructor and
Rafael Espindola [Mon, 15 Sep 2014 18:46:13 +0000 (18:46 +0000)]
Create a emitCXXStructor function and make the existing emitCXXConstructor and
emitCXXDestructor static helpers.

A next patch will make it a helper in CGCXXABI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217804 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoUse intrusive refcounted pointers to manage RopeRefCountString lifetime.
Benjamin Kramer [Mon, 15 Sep 2014 17:58:03 +0000 (17:58 +0000)]
Use intrusive refcounted pointers to manage RopeRefCountString lifetime.

std::shared_ptr<char []> would be even nicer, but shared_ptr doesn't work
with arrays :(

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217798 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agounique_ptrify ChainedDiagnosticConsumer's ctor parameters
David Blaikie [Mon, 15 Sep 2014 17:50:10 +0000 (17:50 +0000)]
unique_ptrify ChainedDiagnosticConsumer's ctor parameters

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217793 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoTeach Clang how to use response files when calling other tools
Reid Kleckner [Mon, 15 Sep 2014 17:45:39 +0000 (17:45 +0000)]
Teach Clang how to use response files when calling other tools

Patch by Rafael Auler!

This patch addresses PR15171 and teaches Clang how to call other tools
with response files, when the command line exceeds system limits. This
is a problem for Windows systems, whose maximum command-line length is
32kb.

I introduce the concept of "response file support" for each Tool object.
A given Tool may have full support for response files (e.g. MSVC's
link.exe) or only support file names inside response files, but no flags
(e.g. Apple's ld64, as commented in PR15171), or no support at all (the
default case). Therefore, if you implement a toolchain in the clang
driver and you want clang to be able to use response files in your
tools, you must override a method (getReponseFileSupport()) to tell so.

I designed it to support different kinds of tools and
internationalisation needs:

- VS response files ( UTF-16 )
- GNU tools ( uses system's current code page, windows' legacy intl.
  support, with escaped backslashes. On unix, fallback to UTF-8 )
- Clang itself ( UTF-16 on windows, UTF-8 on unix )
- ld64 response files ( only a limited file list, UTF-8 on unix )

With this design, I was able to test input file names with spaces and
international characters for Windows. When the linker input is large
enough, it creates a response file with the correct encoding. On a Mac,
to test ld64, I temporarily changed Clang's behavior to always use
response files regardless of the command size limit (avoiding using huge
command line inputs). I tested clang with the LLVM test suite (compiling
benchmarks) and it did fine.

Test Plan: A LIT test that tests proper response files support. This is
tricky, since, for Unix systems, we need a 2MB response file, otherwise
Clang will simply use regular arguments instead of a response file. To
do this, my LIT test generate the file on the fly by cloning many -DTEST
parameters until we have a 2MB file. I found out that processing 2MB of
arguments is pretty slow, it takes 1 minute using my notebook in a debug
build, or 10s in a Release build. Therefore, I also added "REQUIRES:
long_tests", so it will only run when the user wants to run long tests.

In the full discussion in
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130408/171463.html,
Rafael Espindola discusses a proper way to test
llvm::sys::argumentsFitWithinSystemLimits(), and, there, Chandler
suggests to use 10 times the current system limit (20MB resp file), so
we guarantee that the system will always use response file, even if a
new linux comes up that can handle a few more bytes of arguments.
However, by testing with a 20MB resp file, the test takes long 8 minutes
just to perform a silly check to see if the driver will use a response
file. I found it to be unreasonable. Thus, I discarded this approach and
uses a 2MB response file, which should be enough.

Reviewers: asl, rafael, silvas

Reviewed By: silvas

Subscribers: silvas, rnk, thakis, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217792 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoFix memory leak of raw_ostreams in LogDiagnosticPrinter handling.
David Blaikie [Mon, 15 Sep 2014 17:30:56 +0000 (17:30 +0000)]
Fix memory leak of raw_ostreams in LogDiagnosticPrinter handling.

This is another case of conditional ownership (in this case a raw
reference, plus a boolean to indicate whether the referenced object
should be deleted). While it's not ideal, I prefer to make the ownership
explicit with a unique_ptr than using a boolean flag (though it does
make the reference and the unique_ptr redundant in the sense that they
both refer to the same memory). At some point we might write a reusable
conditional ownership pointer (a stateful custom deleter for a unique_ptr
may be appropriate).

Based on a patch from a patch by Anton Yartsev.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217791 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdd -fseh-exceptions for MinGW-w64
Reid Kleckner [Mon, 15 Sep 2014 17:19:16 +0000 (17:19 +0000)]
Add -fseh-exceptions for MinGW-w64

This adds a flag called -fseh-exceptions that uses the native Windows
.pdata and .xdata unwind mechanism to throw exceptions. The other EH
possibilities are DWARF and SJLJ exceptions.

Patch by Martell Malone!

Reviewed By: asl, rnk

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217790 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoPretty print attributes associated with record declarations.
Aaron Ballman [Mon, 15 Sep 2014 16:45:30 +0000 (16:45 +0000)]
Pretty print attributes associated with record declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217784 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoObjective-C SDK modernizer. Do not modernize an enum
Fariborz Jahanian [Mon, 15 Sep 2014 16:41:47 +0000 (16:41 +0000)]
Objective-C SDK modernizer. Do not modernize an enum
which already has the underlying interger type specification.
// rdar://1826225

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217783 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdding some FIXMEs to the attribute emitter code regarding whether pretty printing...
Aaron Ballman [Mon, 15 Sep 2014 16:16:14 +0000 (16:16 +0000)]
Adding some FIXMEs to the attribute emitter code regarding whether pretty printing enumerators should use quoted string literals, or identifiers. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217781 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoWhen pretty printing attributes that have enumeration arguments, print the enumerator...
Aaron Ballman [Mon, 15 Sep 2014 15:14:13 +0000 (15:14 +0000)]
When pretty printing attributes that have enumeration arguments, print the enumerator identifier (as a string literal) instead of the internal enumerator integral value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217771 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoEdit: Do not extend a removal to include trailing whitespace if we're at the end
Benjamin Kramer [Mon, 15 Sep 2014 11:47:10 +0000 (11:47 +0000)]
Edit: Do not extend a removal to include trailing whitespace if we're at the end
of the file.

This would run past the end of the buffer. Sadly I don't have a great way to
test it, the only way to trigger the bug is having a removal fix it at the end
of the file, which none of our current warnings can generate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217766 91177308-0d34-0410-b5e6-96231b3b80d8

10 years ago[ARM] Add ACLE predefines: maxmin, rounding and h/w integer division
James Molloy [Mon, 15 Sep 2014 11:25:38 +0000 (11:25 +0000)]
[ARM] Add ACLE predefines: maxmin, rounding and h/w integer division

Patch by Assad Hashmi!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217760 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoclang-format: Basic support for Java.
Daniel Jasper [Mon, 15 Sep 2014 11:21:46 +0000 (11:21 +0000)]
clang-format: Basic support for Java.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217759 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoclang-format: Add option to break before non-assignment operators.
Daniel Jasper [Mon, 15 Sep 2014 11:11:00 +0000 (11:11 +0000)]
clang-format: Add option to break before non-assignment operators.

This will allow:
  int aaaaaaaaaaaaaa =
      bbbbbbbbbbbbbb
      + ccccccccccccccc;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217757 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMake test/Driver hermetic
JF Bastien [Sun, 14 Sep 2014 23:42:15 +0000 (23:42 +0000)]
Make test/Driver hermetic

Summary:
The includes shouldn't be there, use the compiler's built-in types/macros instead.

This is a follow-up to r217694, as discussed in:
  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140908/114669.html

Test Plan: ninja check-clang

Reviewers: nlewycky, thakis, echristo, chandlerc

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217743 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoCheck delegating constructors for using uninitialized fields.
Richard Trieu [Fri, 12 Sep 2014 22:47:58 +0000 (22:47 +0000)]
Check delegating constructors for using uninitialized fields.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217716 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoclang-cl: Warn when a /TC or /TP argument is unused
Ehsan Akhgari [Fri, 12 Sep 2014 21:44:24 +0000 (21:44 +0000)]
clang-cl: Warn when a /TC or /TP argument is unused

Test Plan: The patch includes a test case.

Reviewers: hansw

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217710 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoDon't print 'NULL TYPE' when dumping a delegating constructor.
Richard Trieu [Fri, 12 Sep 2014 21:20:53 +0000 (21:20 +0000)]
Don't print 'NULL TYPE' when dumping a delegating constructor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217707 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAllow protocols to be just declared.
Rafael Espindola [Fri, 12 Sep 2014 20:14:20 +0000 (20:14 +0000)]
Allow protocols to be just declared.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217704 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agopatch to add missing warning on sizeof wrong parameter
Fariborz Jahanian [Fri, 12 Sep 2014 18:44:36 +0000 (18:44 +0000)]
patch to add missing warning on sizeof wrong parameter
for __builtin___strlcpy_chk/__builtin___strlcat_chk.
Patch by Jacques Fortier with monir change by me and
addition of test. rdar://18259539

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217700 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoclang-cl: Don't treat linker input files differently when /TP or /TC is specified.
Ehsan Akhgari [Fri, 12 Sep 2014 18:15:10 +0000 (18:15 +0000)]
clang-cl: Don't treat linker input files differently when /TP or /TC is specified.

Summary: This fixes http://llvm.org/PR20923.

Test Plan: This patch includes an automated test.

Reviewers: hansw

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217699 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoNo need to use PNaCl's calling convention since PNaCl now uses a separate approach...
JF Bastien [Fri, 12 Sep 2014 17:52:51 +0000 (17:52 +0000)]
No need to use PNaCl's calling convention since PNaCl now uses a separate approach for calling conventions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217696 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoFix copy/paste for test, the triple should be le64-unknown-unknown
JF Bastien [Fri, 12 Sep 2014 17:52:49 +0000 (17:52 +0000)]
Fix copy/paste for test, the triple should be le64-unknown-unknown

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217695 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdd support for le64.
JF Bastien [Fri, 12 Sep 2014 17:52:47 +0000 (17:52 +0000)]
Add support for le64.

Summary:
le64 is a generic little-endian 64-bit processor, mimicking le32.

Also see the associated LLVM change.

Test Plan: make check-all

Reviewers: dschuff

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217694 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoclang-format: Improve line breaks at function calls.
Daniel Jasper [Fri, 12 Sep 2014 16:35:28 +0000 (16:35 +0000)]
clang-format: Improve line breaks at function calls.

Before:
  EXPECT_CALL(SomeObject, SomeFunction(Parameter)).Times(2).WillRepeatedly(
      Return(SomeValue));

After:
  EXPECT_CALL(SomeObject, SomeFunction(Parameter))
      .Times(2)
      .WillRepeatedly(Return(SomeValue));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217687 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdd a previously-missing test case for return adjustment vs pure virtual methods
Timur Iskhodzhanov [Fri, 12 Sep 2014 15:21:44 +0000 (15:21 +0000)]
Add a previously-missing test case for return adjustment vs pure virtual methods

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217686 91177308-0d34-0410-b5e6-96231b3b80d8

10 years ago[ASan/Win] Fix PR20918 -- SEH handler doesn't work with the MD runtime
Timur Iskhodzhanov [Fri, 12 Sep 2014 14:01:30 +0000 (14:01 +0000)]
[ASan/Win] Fix PR20918 -- SEH handler doesn't work with the MD runtime

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217679 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoUpdate the test case after r217673
Timur Iskhodzhanov [Fri, 12 Sep 2014 13:47:44 +0000 (13:47 +0000)]
Update the test case after r217673

Sorry, committing to multiple repos at once is hard...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217677 91177308-0d34-0410-b5e6-96231b3b80d8

10 years ago[ASan/Win] Rename asan_win_uar_thunk.lib to asan_win_dynamic_runtime_thunk.lib
Timur Iskhodzhanov [Fri, 12 Sep 2014 13:21:02 +0000 (13:21 +0000)]
[ASan/Win] Rename asan_win_uar_thunk.lib to asan_win_dynamic_runtime_thunk.lib

It turned out that we have to bridge more stuff between the executable
and the ASan RTL DLL than just __asan_option_detect_stack_use_after_return.
See PR20918 for more details.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217673 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoFixing a -Woverflow warning from GCC by using a more natural datatype for this operat...
Aaron Ballman [Fri, 12 Sep 2014 12:42:15 +0000 (12:42 +0000)]
Fixing a -Woverflow warning from GCC by using a more natural datatype for this operation. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217670 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoEvery code owner should be reachable via email, so add one for
Joerg Sonnenberger [Fri, 12 Sep 2014 08:05:51 +0000 (08:05 +0000)]
Every code owner should be reachable via email, so add one for
Douglas Gregor and Ted Kremenek.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217658 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoUse unique_ptr for ScratchBuf and PragmaHandlers in the preprocessor.
Craig Topper [Fri, 12 Sep 2014 05:19:24 +0000 (05:19 +0000)]
Use unique_ptr for ScratchBuf and PragmaHandlers in the preprocessor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217656 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMS ABI: The latest VC "14" CTP implements deleted virtual functions
David Majnemer [Fri, 12 Sep 2014 04:38:08 +0000 (04:38 +0000)]
MS ABI: The latest VC "14" CTP implements deleted virtual functions

Deleted virtual functions get _purecall inserted into the vftable.
Earlier CTPs would simply stick nullptr in there.

N.B.  MSVC can't handle deleted virtual functions which require return
adjusting thunks, they give an error that a deleted function couldn't be
called inside of a compiler generated function.  We get this correct by
making the thunk have a __purecall entry as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217654 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMS ABI: Use the correct this arg when generating implict copy ctor
David Majnemer [Thu, 11 Sep 2014 23:05:02 +0000 (23:05 +0000)]
MS ABI: Use the correct this arg when generating implict copy ctor

We assumed that the incoming this argument would be the last argument.

However, this is not true under the MS ABI.

This fixes PR20897.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217642 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoThread Safety Analysis: Avoid infinite recursion in an operator<<
Justin Bogner [Thu, 11 Sep 2014 19:44:04 +0000 (19:44 +0000)]
Thread Safety Analysis: Avoid infinite recursion in an operator<<

r217556 introduced an operator<<(std::ostream &, StringRef) that seems
to self recurse on some systems, because str.data(), which is a char *,
was being implicitly converted back to StringRef in overload
resolution.

This manifested as SemaCXX/warn-thread-safety-analysis.cpp timing out
in release builds and overflowing the stack in debug builds. One of
the failing systems that saw this is here:

  http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-nobootstrap-RAincremental/builds/4636

Using ostream's write method instead of operator<< should get the bots
going again.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217621 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoObjective-C. Under a special flag, -Wcstring-format-directive,
Fariborz Jahanian [Thu, 11 Sep 2014 19:13:23 +0000 (19:13 +0000)]
Objective-C. Under a special flag, -Wcstring-format-directive,
off by default, issue a warning if %s directive is used
in formart argument of a function/method declared as
__attribute__((format(CF/NSString, ...)))
To complete rdar://18182443

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217619 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoclang-cl: Add support for the /o option for object files, executables, and preprocess...
Ehsan Akhgari [Thu, 11 Sep 2014 18:16:21 +0000 (18:16 +0000)]
clang-cl: Add support for the /o option for object files, executables, and preprocessor output

Summary:
cl.exe recognizes /o as a deprecated and undocumented option similar to
/Fe.  This patch adds support for this option to clang-cl for /Fe, /Fo
and /Fi.  It also ensures that the last option among /o and /F* wins,
if both specified.

This is required at least for building autoconf based software, since
autoconf uses -o to specify the executable output.

This fixes http://llvm.org/PR20894.

Test Plan: The patch includes automated tests.

Reviewers: rnk

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217615 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoUse the simpler version of llvm::sys::fs::exists.
Rafael Espindola [Thu, 11 Sep 2014 18:10:13 +0000 (18:10 +0000)]
Use the simpler version of llvm::sys::fs::exists.

In all these cases it looks like the intention was to handle error in a similar
way to the file not existing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217614 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoUpdate C++ status page to reflect that Clang 3.5 has released.
Richard Smith [Thu, 11 Sep 2014 17:30:32 +0000 (17:30 +0000)]
Update C++ status page to reflect that Clang 3.5 has released.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217609 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoUpdate DR status list to reflect that Clang 3.5 has been released.
Richard Smith [Thu, 11 Sep 2014 17:29:13 +0000 (17:29 +0000)]
Update DR status list to reflect that Clang 3.5 has been released.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217608 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoTests for DR573-580.
Richard Smith [Thu, 11 Sep 2014 17:28:14 +0000 (17:28 +0000)]
Tests for DR573-580.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217606 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMerge GetAddrOfCXXConstructor and GetAddrOfCXXDonstructor. NFC.
Rafael Espindola [Thu, 11 Sep 2014 15:42:06 +0000 (15:42 +0000)]
Merge GetAddrOfCXXConstructor and GetAddrOfCXXDonstructor. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217598 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoFix bug 20892 - clang-format does not handle C-style comments
Roman Kashitsyn [Thu, 11 Sep 2014 14:47:20 +0000 (14:47 +0000)]
Fix bug 20892 - clang-format does not handle C-style comments

Summary:
http://llvm.org/bugs/show_bug.cgi?id=20892

Add support of C-style formatting enabling/disabling directives. Now the following two styles are supported:

  // clang-format on
  /* clang-format on */

The flexibility in comments (support of extra spaces and/or slashes, etc.) is deliberately avoided to simplify search in large code bases.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, curdeius, klimek

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217588 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAvoid some unnecessary SmallVector copies.
Benjamin Kramer [Thu, 11 Sep 2014 14:13:49 +0000 (14:13 +0000)]
Avoid some unnecessary SmallVector copies.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217586 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoNULL->nullptr
Alexander Musman [Thu, 11 Sep 2014 08:10:57 +0000 (08:10 +0000)]
NULL->nullptr

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217573 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoFix a couple of -Wsign-compare warnings introduced in r217556
Justin Bogner [Thu, 11 Sep 2014 03:37:42 +0000 (03:37 +0000)]
Fix a couple of -Wsign-compare warnings introduced in r217556

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217569 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoThread Safety Analysis: major update to thread safety TIL.
DeLesley Hutchins [Wed, 10 Sep 2014 22:12:52 +0000 (22:12 +0000)]
Thread Safety Analysis: major update to thread safety TIL.
Numerous changes, including:
  * Changed the way variables and instructions are handled in basic blocks to
    be more efficient.
  * Eliminated SExprRef.
  * Simplified futures.
  * Fixed documentation.
  * Compute dominator and post dominator trees.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217556 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMore test for "void *" argument as index of a dictionary literal.
Fariborz Jahanian [Wed, 10 Sep 2014 22:12:13 +0000 (22:12 +0000)]
More test for "void *" argument as index of a dictionary literal.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217555 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoRemove a couple of fixed paths that snuck into my test from 217550
Ben Langmuir [Wed, 10 Sep 2014 21:41:43 +0000 (21:41 +0000)]
Remove a couple of fixed paths that snuck into my test from 217550

I forgot to fix these again the second time I copy-and-pasted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217552 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAvoid a couple of assertions when preprocessing with modules
Ben Langmuir [Wed, 10 Sep 2014 21:29:41 +0000 (21:29 +0000)]
Avoid a couple of assertions when preprocessing with modules

1. We were hitting the NextIsPrevious assertion because we were trying
to merge decl chains that were independent of each other because we had
no Sema object to allow them to find existing decls. This is fixed by
delaying loading the "preloaded" decls until Sema is available.

2. We were trying to get identifier info from an annotation token, which
asserts.  The fix is to special-case the module annotations in the
preprocessed output printer.

Fixed in a single commit because when you hit 1 you almost invariably
hit 2 as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217550 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoUpdate for llvm api change.
Rafael Espindola [Wed, 10 Sep 2014 21:27:41 +0000 (21:27 +0000)]
Update for llvm api change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217547 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoOnly override the target architecture on -m32 and friends if it is
Joerg Sonnenberger [Wed, 10 Sep 2014 21:25:37 +0000 (21:25 +0000)]
Only override the target architecture on -m32 and friends if it is
actually different. Fixes a surprising link error with nodejs on rpi,
where armv6-netbsd-eabihf turned into armv5e-netbsd-eabihf, which
doesn't lacks the necessary VFP support.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217546 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoObjective-C. Accept 'nil' as indexing argument to
Fariborz Jahanian [Wed, 10 Sep 2014 20:55:31 +0000 (20:55 +0000)]
Objective-C. Accept 'nil' as indexing argument to
dictionary literals since the API which implements
them accepts it too.  // rdar://18254621

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217543 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMS ABI: Emit dynamic initializers for selectany globals in comdat-associative section...
Hans Wennborg [Wed, 10 Sep 2014 19:28:48 +0000 (19:28 +0000)]
MS ABI: Emit dynamic initializers for selectany globals in comdat-associative sections (PR20889)

This prevents initializers for comdat-folded globals from running multiple times.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217534 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoObjective-C arc. Fixes a crash when issuing diagnostic for
Fariborz Jahanian [Wed, 10 Sep 2014 18:23:34 +0000 (18:23 +0000)]
Objective-C arc. Fixes a crash when issuing diagnostic for
passing parameter to an audited CF API. rdar://18222007

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217530 91177308-0d34-0410-b5e6-96231b3b80d8

10 years ago[sphinx cleanup]
Dan Liew [Wed, 10 Sep 2014 17:26:21 +0000 (17:26 +0000)]
[sphinx cleanup]
Fix sphinx warning introduced by r217501.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217524 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoRecognize .lib files as linker input explicitly
Ehsan Akhgari [Wed, 10 Sep 2014 17:15:00 +0000 (17:15 +0000)]
Recognize .lib files as linker input explicitly

Summary:
Currently, this is done implicitly in Driver::BuildInputs by considering
any invalid input type as linker input.

Test Plan: I don't think this behavior is observable for the reason stated above.

Reviewers: hansw

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217522 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdd a test for an operator access decl.
Nico Weber [Wed, 10 Sep 2014 17:03:37 +0000 (17:03 +0000)]
Add a test for an operator access decl.

In Parser::ParseCXXClassMemberDeclaration(), it was possible to change
      isAccessDecl = NextToken().is(tok::kw_operator);
to
      isAccessDecl = false;
and no tests would fail. Now there's coverage for this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217519 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agotypo
Sanjay Patel [Wed, 10 Sep 2014 16:59:01 +0000 (16:59 +0000)]
typo

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217517 91177308-0d34-0410-b5e6-96231b3b80d8

10 years ago[analyzer] Fix pthread lock tests so that the API comes from a system header.
Jordan Rose [Wed, 10 Sep 2014 16:17:42 +0000 (16:17 +0000)]
[analyzer] Fix pthread lock tests so that the API comes from a system header.

...and verify that a global mutex in user code can be used without warnings.

Patch by Aleksei Sidorin!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217515 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoclang-format: Add option to allow short case labels on a single line.
Daniel Jasper [Wed, 10 Sep 2014 13:11:45 +0000 (13:11 +0000)]
clang-format: Add option to allow short case labels on a single line.

On a single line:
  switch (a) {
  case 1: x = 1; return;
  case 2: x = 2; return;
  default: break;
  }

Not on a single line:
  switch (a) {
  case 1:
    x = 1;
    return;
  case 2:
    x = 2;
    return;
  default:
    break;
  }

This partly addresses llvm.org/PR16535. In the long run, we probably want to
lay these out in columns.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217501 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoCodeGen: Use a fixed alignment for vtables.
Benjamin Kramer [Wed, 10 Sep 2014 12:50:59 +0000 (12:50 +0000)]
CodeGen: Use a fixed alignment for vtables.

Pointer-sized alignment is sufficient as we only ever read single values
from the table. Otherwise we'd bump the alignment to 16 bytes in the
backend if the vtable is larger than 16 bytes. This is great for
structures that are accessed with vector instructions or copied around, but
that's simply not the case for vtables.

Shrinks the data segment of a Release x86_64 clang by 0.3%. The wins are
larger for i386 and code bases that use vtables more often than we do.

This matches the behavior of GCC 5.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217495 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoRevert over-eager unique_ptr conversion.
Benjamin Kramer [Wed, 10 Sep 2014 09:35:49 +0000 (09:35 +0000)]
Revert over-eager unique_ptr conversion.

This test wants to observe PPCallbacks after they have been moved into the
preprocessor. That doesn't work if the pointer has been moved away.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217481 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoUnique_ptrify PPCallbacks ownership.
Craig Topper [Wed, 10 Sep 2014 04:53:53 +0000 (04:53 +0000)]
Unique_ptrify PPCallbacks ownership.

Unique_ptr creation stil needs to be moved earlier at some of the call sites.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217474 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoDon't crash on access decls with invalid scope specifier, PR20887.
Nico Weber [Wed, 10 Sep 2014 00:59:37 +0000 (00:59 +0000)]
Don't crash on access decls with invalid scope specifier, PR20887.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217472 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoObjective-C. Under a special flag, -Wcstring-format-directive,
Fariborz Jahanian [Tue, 9 Sep 2014 23:10:54 +0000 (23:10 +0000)]
Objective-C. Under a special flag, -Wcstring-format-directive,
off by default, issue a warning if %s directive is used in
certain CF/NS formatting APIs, to assist user in deprecating
use of such %s in these APIs. rdar://18182443

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217467 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoTeach the analyzer that __builtin_assume_aligned returns its first argument.
Jordan Rose [Tue, 9 Sep 2014 21:42:16 +0000 (21:42 +0000)]
Teach the analyzer that __builtin_assume_aligned returns its first argument.

Patch by Daniel Fahlgren!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217461 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoclang-format: [JS] Support regex literals with trailing escaped slash.
Daniel Jasper [Tue, 9 Sep 2014 14:37:39 +0000 (14:37 +0000)]
clang-format: [JS] Support regex literals with trailing escaped slash.

Before:
  var regex = / a\//; int i;

After:
  var regex = /a\//;
  int i;

This required pushing the Lexer into its wrapper class and generating a
new one in this specific case. Otherwise, the sequence get lexed as a
//-comment. This is hacky, but I don't know a better way (short of
supporting regex literals in the Lexer).

Pushing the Lexer down seems to make all the call sites simpler.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217444 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoTooling: Ignore file names in tooling::deduplicate.
Benjamin Kramer [Tue, 9 Sep 2014 13:53:29 +0000 (13:53 +0000)]
Tooling: Ignore file names in tooling::deduplicate.

This was horribly broken due to how the sort predicate works. We would
report a conflict for files with a replacement in the same position but
different names if the length differed. Just ignore paths as this is often
what the user wants. Files can occur with different names (due to symlinks
or relative paths) and we don't ever want to do the same edit in one file
twice.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217439 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAllow empty statements in naked functions in addition to ASM statements
Ehsan Akhgari [Tue, 9 Sep 2014 02:49:40 +0000 (02:49 +0000)]
Allow empty statements in naked functions in addition to ASM statements

Summary: This fixes PR20883.

Test Plan: The patch includes an automated test.

Reviewers: hansw

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217413 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoFix PCHs that import more than one module
Ben Langmuir [Mon, 8 Sep 2014 20:36:26 +0000 (20:36 +0000)]
Fix PCHs that import more than one module

We were passing < to std::unique, but it expects ==. Since the input is
sorted, we were always trimming it to one entry.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217402 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoReport source location of returns_nonnull attribute in UBSan reports.
Alexey Samsonov [Mon, 8 Sep 2014 20:17:19 +0000 (20:17 +0000)]
Report source location of returns_nonnull attribute in UBSan reports.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217400 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoImplement nonnull-attribute sanitizer
Alexey Samsonov [Mon, 8 Sep 2014 17:22:45 +0000 (17:22 +0000)]
Implement nonnull-attribute sanitizer

Summary:
This patch implements a new UBSan check, which verifies
that function arguments declared to be nonnull with __attribute__((nonnull))
are actually nonnull in runtime.

To implement this check, we pass FunctionDecl to CodeGenFunction::EmitCallArgs
(where applicable) and if function declaration has nonnull attribute specified
for a certain formal parameter, we compare the corresponding RValue to null as
soon as it's calculated.

Test Plan: regression test suite

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cfe-commits, rnk

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217389 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoRemove a parameter that has been unused since r188481. No behavior change.
Nico Weber [Mon, 8 Sep 2014 16:26:36 +0000 (16:26 +0000)]
Remove a parameter that has been unused since r188481. No behavior change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217386 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMake FileEntry::getName() valid across calls to FileManager::getFile()
Ben Langmuir [Mon, 8 Sep 2014 16:15:54 +0000 (16:15 +0000)]
Make FileEntry::getName() valid across calls to FileManager::getFile()

Because we may change the name of a FileEntry inside getFile, the name
returned by FileEntry::getName() could be destroyed.  This was causing a
use-after-free when searching the HeaderFileInfo on-disk hashtable for a
module or pch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217385 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdd a comment for something that confused me.
Nico Weber [Mon, 8 Sep 2014 16:11:15 +0000 (16:11 +0000)]
Add a comment for something that confused me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217384 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoHandle constructors and destructors a bit more uniformly in CodeGen.
Rafael Espindola [Mon, 8 Sep 2014 16:01:27 +0000 (16:01 +0000)]
Handle constructors and destructors a bit more uniformly in CodeGen.

There were code paths that are duplicated for constructors and destructors just
because we have both CXXCtorType and CXXDtorsTypes.

This patch introduces an unified enum and reduces code deplication a bit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217383 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdd .clang-tidy configuration file to provide LLVM-optimized defaults for clang-tidy.
Alexander Kornienko [Mon, 8 Sep 2014 13:33:32 +0000 (13:33 +0000)]
Add .clang-tidy configuration file to provide LLVM-optimized defaults for clang-tidy.

Reviewers: chandlerc, djasper, alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217366 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoclang/test/CodeGen/builtin-assume*.c: Fixup for -Asserts.
NAKAMURA Takumi [Mon, 8 Sep 2014 01:12:55 +0000 (01:12 +0000)]
clang/test/CodeGen/builtin-assume*.c: Fixup for -Asserts.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217352 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoDon't test really-large alignments for now
Hal Finkel [Mon, 8 Sep 2014 00:09:15 +0000 (00:09 +0000)]
Don't test really-large alignments for now

Temporarily comment out the test for really-large powers of two. This seems to
be host-sensitive for some reason... trying to fix the clang-i386-freebsd
builder.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217351 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdd __builtin_assume and __builtin_assume_aligned using @llvm.assume.
Hal Finkel [Sun, 7 Sep 2014 22:58:14 +0000 (22:58 +0000)]
Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.

This makes use of the recently-added @llvm.assume intrinsic to implement a
__builtin_assume(bool) intrinsic (to provide additional information to the
optimizer). This hooks up __assume in MS-compatibility mode to mirror
__builtin_assume (the semantics have been intentionally kept compatible), and
implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM
now contains special logic to deal with assumptions of this form.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217349 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdjust test/CodeGenCXX/pr12251.cpp
Hal Finkel [Sun, 7 Sep 2014 21:28:53 +0000 (21:28 +0000)]
Adjust test/CodeGenCXX/pr12251.cpp

InstCombine just got a bit smarter about checking known bits of returned
values, and because this test runs the optimizer, it requires an update. We
should really rewrite this test to directly check the IR output from CodeGen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217347 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAvoid writing to the test directory as it may not be writable.
David Blaikie [Sun, 7 Sep 2014 17:34:18 +0000 (17:34 +0000)]
Avoid writing to the test directory as it may not be writable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217339 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoFix test to not write output to the test directory, as it may not be writable.
David Blaikie [Sun, 7 Sep 2014 16:59:13 +0000 (16:59 +0000)]
Fix test to not write output to the test directory, as it may not be writable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217337 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoTry to green test/Sema/format-strings.c on Win bots
Hans Wennborg [Sun, 7 Sep 2014 04:03:21 +0000 (04:03 +0000)]
Try to green test/Sema/format-strings.c on Win bots

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217327 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMS format strings: parse the 'Z' printf conversion specifier (PR20808)
Hans Wennborg [Sun, 7 Sep 2014 03:03:51 +0000 (03:03 +0000)]
MS format strings: parse the 'Z' printf conversion specifier (PR20808)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217326 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMove x86-specific bits of warn-unused-local-typedef.cpp into their own file.
Nico Weber [Sat, 6 Sep 2014 18:16:37 +0000 (18:16 +0000)]
Move x86-specific bits of warn-unused-local-typedef.cpp into their own file.

That way, most of the test can run everywhere. Also give the new file an x86
triple in addition to a REQUIRES line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217314 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAttempt to fix ARM bot. (The test references a typedef from x86 asm.)
Nico Weber [Sat, 6 Sep 2014 15:48:53 +0000 (15:48 +0000)]
Attempt to fix ARM bot. (The test references a typedef from x86 asm.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217313 91177308-0d34-0410-b5e6-96231b3b80d8

10 years ago[x86] Clean up the x86 builtin specs to reflect r217310 in LLVM which
Chandler Carruth [Sat, 6 Sep 2014 10:30:51 +0000 (10:30 +0000)]
[x86] Clean up the x86 builtin specs to reflect r217310 in LLVM which
made the 8-bit masks actually 8-bit arguments to these intrinsics.

These builtins are a mess. Many were missing the I qualifier which
I added where obviously correct. Most aren't tested, but I've updated
the relevant tests. I've tried to catch all the things that should
become 'c' in this round.

It's also frustrating because the set of these is really ad-hoc and
doesn't really map that cleanly to the set supported by either GCC or
LLVM. Oh well...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217311 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdd error, recovery and fixit for "~A::A() {...}".
Richard Smith [Sat, 6 Sep 2014 02:06:12 +0000 (02:06 +0000)]
Add error, recovery and fixit for "~A::A() {...}".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217302 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoAdd -Wunused-local-typedef, a warning that finds unused local typedefs.
Nico Weber [Sat, 6 Sep 2014 01:25:55 +0000 (01:25 +0000)]
Add -Wunused-local-typedef, a warning that finds unused local typedefs.

The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases --
that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls
wasn't used for anything before this warning it wasn't always set correctly,
so this patch also adds a few missing MarkAnyDeclReferenced() calls in
various places for TypedefNameDecls.

This is made a bit complicated due to local typedefs possibly being used only
after their local scope has closed. Consider:

    template <class T>
    void template_fun(T t) {
      typename T::Foo s3foo;  // YYY
      (void)s3foo;
    }
    void template_fun_user() {
      struct Local {
        typedef int Foo;  // XXX
      } p;
      template_fun(p);
    }

Here the typedef in XXX is only used at end-of-translation unit, when YYY in
template_fun() gets instantiated. To handle this, typedefs that are unused when
their scope exits are added to a set of potentially unused typedefs, and that
set gets checked at end-of-TU. Typedefs that are still unused at that point then
get warned on. There's also serialization code for this set, so that the
warning works with precompiled headers and modules. For modules, the warning
is emitted when the module is built, for precompiled headers each time the
header gets used.

Finally, consider a function using C++14 auto return types to return a local
type defined in a header:

    auto f() {
      struct S { typedef int a; };
      return S();
    }

Here, the typedef escapes its local scope and could be used by only some
translation units including the header. To not warn on this, add a
RecursiveASTVisitor that marks all delcs on local types returned from auto
functions as referenced. (Except if it's a function with internal linkage, or
the decls are private and the local type has no friends -- in these cases, it
_is_ safe to warn.)

Several of the included testcases (most of the interesting ones) were provided
by Richard Smith.

(gcc's spelling -Wunused-local-typedefs is supported as an alias for this
warning.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217298 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoReword switch/goto diagnostics "protected scope" diagnostics. Making up a term
Richard Smith [Sat, 6 Sep 2014 00:24:58 +0000 (00:24 +0000)]
Reword switch/goto diagnostics "protected scope" diagnostics. Making up a term
"protected scope" is very unhelpful here and actively confuses users. Instead,
simply state the nature of the problem in the diagnostic: we cannot jump from
here to there. The notes explain nicely why not.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217293 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoFix r217275 to work without the need for standard headers being included
David Blaikie [Fri, 5 Sep 2014 23:36:59 +0000 (23:36 +0000)]
Fix r217275 to work without the need for standard headers being included

It seems (I guess) in ObjC that va_list is provided without the need for
inclusions. I verified that with this change the test still crashes in
the absence of the fix committed in r217275.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217290 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoMove the initialization of VAListTagName after InitializeSema()
Ben Langmuir [Fri, 5 Sep 2014 20:24:27 +0000 (20:24 +0000)]
Move the initialization of VAListTagName after InitializeSema()

This innocuous statement to get the identifier info for __va_list_tag
was causing an assertion failure:
  NextIsPrevious() && "decl became non-canonical unexpectedly"
if the __va_list_tag identifier was found in a PCH in some
circumstances, because it was looked up before the ASTReader had a Sema
object to use to find existing decls to merge with.

We could possibly move getting the identifier info even later, or make
it lazy if we wanted to, but this seemed like the minimal change.

Now why a PCH would have this identifier in the first place is a bit
mysterious. This seems to be related to the global module index in some
way, because when the test case is built without the global module index
it will not emit an identifier for __va_list_tag into the PCH, but with
the global module index it does.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217275 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoSeparate the matchers by type and statically dispatch to the right list.
Samuel Benzaquen [Fri, 5 Sep 2014 20:15:31 +0000 (20:15 +0000)]
Separate the matchers by type and statically dispatch to the right list.

Summary:
Separate the matchers by type and statically dispatch to the right list.
For any node type that we support, it reduces the number of matchers we
run it through.
For node types we do not support, it makes match() a noop.
This change improves our clang-tidy related benchmark by ~30%.

Reviewers: klimek

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217274 91177308-0d34-0410-b5e6-96231b3b80d8

10 years agoRequire an x86 target for ms-inline-asm-return.cpp instead of XFAIL
Reid Kleckner [Fri, 5 Sep 2014 20:06:06 +0000 (20:06 +0000)]
Require an x86 target for ms-inline-asm-return.cpp instead of XFAIL

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217272 91177308-0d34-0410-b5e6-96231b3b80d8

10 years ago-frewrite-includes: Normalize line endings to match the main source file
Reid Kleckner [Fri, 5 Sep 2014 16:49:50 +0000 (16:49 +0000)]
-frewrite-includes: Normalize line endings to match the main source file

It is very common to include headers with DOS-style line endings, such
as windows.h, from source files with Unix-style line endings.
Previously, we would end up with mixed line endings and #endifs that
appeared to be on the same line:

  #if 0 /* expanded by -frewrite-includes */
  #include <windows.h>^M#endif /* expanded by -frewrite-includes */

Clang treats either of \r or \n as a line ending character, so this is
purely a cosmetic issue.

This has no automated test because most Unix tools on Windows will
implictly convert CRLF to LF when reading files, making it very hard to
detect line ending mismatches. FileCheck doesn't understand {{\r}}
either.

Fixes PR20552.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217259 91177308-0d34-0410-b5e6-96231b3b80d8

10 years ago[analyzer] Don't crash if malloc() has an unexpected function prototype.
Jordan Rose [Fri, 5 Sep 2014 16:33:51 +0000 (16:33 +0000)]
[analyzer] Don't crash if malloc() has an unexpected function prototype.

Patch by Daniel Fahlgren!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217258 91177308-0d34-0410-b5e6-96231b3b80d8