]> granicus.if.org Git - clang/log
clang
9 years agoClean up a string comparison with StringRef. Suggestion by David Majnemer.
Richard Trieu [Sat, 17 Jan 2015 00:56:10 +0000 (00:56 +0000)]
Clean up a string comparison with StringRef.  Suggestion by David Majnemer.

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

9 years agoRemove std::move that was preventing return value optimization.
Richard Trieu [Sat, 17 Jan 2015 00:46:55 +0000 (00:46 +0000)]
Remove std::move that was preventing return value optimization.

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

9 years agoAdding option -fno-inline-asm to disallow inline asm
Steven Wu [Fri, 16 Jan 2015 23:05:28 +0000 (23:05 +0000)]
Adding option -fno-inline-asm to disallow inline asm

Summary:
This patch add a new option to dis-allow all inline asm.
Any GCC style inline asm will be reported as an error.

Reviewers: rnk, echristo

Reviewed By: rnk, echristo

Subscribers: bob.wilson, rnk, echristo, rsmith, cfe-commits

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

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

9 years agoSuggest objc_method_family(none) for a property named -newFoo or similar.
Jordan Rose [Fri, 16 Jan 2015 23:04:31 +0000 (23:04 +0000)]
Suggest objc_method_family(none) for a property named -newFoo or similar.

As mentioned in the previous commit, if a property (declared with @property)
has a name that matches a special Objective-C method family, the getter picks
up that family despite being declared by the property. The most correct way
to solve this problem is to add the 'objc_method_family' attribute to the
getter with an argument of 'none', which unfortunately requires an explicit
declaration of the getter.

This commit adds a note to the existing error (ARC) or warning (MRR) for
such a poorly-named property that suggests the solution; if there's already
a declaration of the getter, it even includes a fix-it.

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

9 years agoObjC getters with names like "newItem" should still be linked to the @property.
Jordan Rose [Fri, 16 Jan 2015 23:04:26 +0000 (23:04 +0000)]
ObjC getters with names like "newItem" should still be linked to the @property.

Two years ago I added a compile-time "optimization" to
ObjCMethodDecl::findPropertyDecl: exit early if the current method is part
of a special Objective-C method family (like 'new' or 'init'). However, if a
property (declared with @property) has a name that matches a method family,
the getter picks up that family despite being declared by the property. The
early exit then made ObjCMethodDecl::findPropertyDecl decide that there
was no associated property, despite the method itself being marked as an
accessor. This corrects that by removing the early exit.

This does /not/ change the fact that such a getter is considered to return a
value with a +1 retain count. The best way to eliminate this is by adding the
objc_method_family(none) attribute to the getter, but unlike the existing
ns_returns_not_retained that can't be applied directly to the property -- you
have to redeclare the getter instead.

(It'd be nice if @property just implied objc_method_family(none) for its
getter, but that would be a backwards-incompatible change.)

rdar://problem/19038838

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

9 years agoIsolate test for PR22096 to clang.
David Blaikie [Fri, 16 Jan 2015 22:55:09 +0000 (22:55 +0000)]
Isolate test for PR22096 to clang.

Emitting inlinable calls without debug locations (in functions with
debug info, to functions with debug info) is problematic for debug info
when inlining occurs. Test specifically that we don't do that in this
case - thus the test isn't simply "don't crash", it's "include debug
location for this call" (granted it's the wrong location - fix for that
is coming)

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

9 years agoFix a case where delayed typo correction should have resolved an
Kaelyn Takata [Fri, 16 Jan 2015 22:11:04 +0000 (22:11 +0000)]
Fix a case where delayed typo correction should have resolved an
ambiguity but wasn't.

In the new test case, "click" wasn't being corrected properly because
Sema::ClassifyName would call CorrectTypo for "click" then later
Sema::DiagnoseEmptyLookup would call CorrectTypoDelayed for the same use
of "click" (the former by the parser needing to determine what the
identifier is so it knows how to parse the statement, i.e. is it the
beginning of a declaration or an expression). CorrectTypo would record
that typo correction for "click" failed and CorrectTypoDelayed would see
that and not even try to correct the typo, even though in this case
CorrectTypo failed due to an ambiguity (both "Click" and "clock" having
an edit distance of one from "click") that could be resolved with more
information. The fix is two-fold:
  1) Have CorrectTypo not record failed corrections if the reason for
     the failure was two or more corrections with the same edit
     distance, and
  2) Make the CorrectionCandidateCallback used by
     Parser::ParseCastExpression reject FunctionDecl candidates when the
     next token after the identifier is a ".", "=", or "->" since
     functions cannot be assigned to and do not have members that can be
     referenced.

The reason for two correction spots is that from r222549 until r224375
landed, the first correction attempt would fail completely but the
second would suggest "clock" while having the note point to the
declaration of "Click".

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

9 years agoRemove pathname dependence. Also rewrite test to use FileCheck
Eric Christopher [Fri, 16 Jan 2015 22:03:52 +0000 (22:03 +0000)]
Remove pathname dependence. Also rewrite test to use FileCheck
at the same time.

Patch by David Callahan.

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

9 years agoFix some copypasta typos in asserts.
Sean Silva [Fri, 16 Jan 2015 21:44:26 +0000 (21:44 +0000)]
Fix some copypasta typos in asserts.

Fixes PR22236

Patch by Nicolas Brunie! <nicolas.brunie@kalray.eu>

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

9 years agoAlso put vtables in a comdat when rtti is disabled.
Rafael Espindola [Fri, 16 Jan 2015 21:41:44 +0000 (21:41 +0000)]
Also put vtables in a comdat when rtti is disabled.

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

9 years agoWrap to 80 columns. No behavior change.
Nico Weber [Fri, 16 Jan 2015 21:09:43 +0000 (21:09 +0000)]
Wrap to 80 columns. No behavior change.

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

9 years agoAdd comdat to string literal variables on COFF.
Rafael Espindola [Fri, 16 Jan 2015 20:32:35 +0000 (20:32 +0000)]
Add comdat to string literal variables on COFF.

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

9 years agoSpell 0 in an enum-appropriate way. No behavior change.
Nico Weber [Fri, 16 Jan 2015 19:35:01 +0000 (19:35 +0000)]
Spell 0 in an enum-appropriate way. No behavior change.

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

9 years agoDon't crash if a declarator in a friend decl doesn't have a name.
Nico Weber [Fri, 16 Jan 2015 19:34:13 +0000 (19:34 +0000)]
Don't crash if a declarator in a friend decl doesn't have a name.

There was already an explicit check for that for the first decl.  Move that
to a different place so that it's called for the following decls too.  Also
don't randomly set the BitfieldSize ExprResult to true (this sets a pointer to
true internally).

Found by SLi's bot.

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

9 years agoAdd comdats to the RTTI variables in the microsoft abi.
Rafael Espindola [Fri, 16 Jan 2015 19:23:42 +0000 (19:23 +0000)]
Add comdats to the RTTI variables in the microsoft abi.

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

9 years ago[AVX512] Add intrinsics for masked aligned FP loads and stores
Adam Nemet [Fri, 16 Jan 2015 18:51:50 +0000 (18:51 +0000)]
[AVX512] Add intrinsics for masked aligned FP loads and stores

Part of <rdar://problem/17688758>

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

9 years agoFix typo in r225922.
Adam Nemet [Fri, 16 Jan 2015 18:51:46 +0000 (18:51 +0000)]
Fix typo in r225922.

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

9 years agoAArch64: implement AAPCS layout rules for bit-fields.
Tim Northover [Fri, 16 Jan 2015 18:44:04 +0000 (18:44 +0000)]
AArch64: implement AAPCS layout rules for bit-fields.

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

9 years agoAdd comdats to dynamic init functions in the microsoft abi.
Rafael Espindola [Fri, 16 Jan 2015 16:04:45 +0000 (16:04 +0000)]
Add comdats to dynamic init functions in the microsoft abi.

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

9 years agoMake this test a bit stricter. NFC.
Rafael Espindola [Fri, 16 Jan 2015 16:02:03 +0000 (16:02 +0000)]
Make this test a bit stricter. NFC.

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

9 years agoAttempt to fix the build with XCode 5.0.2 (and probably 5.1.1).
Alexander Kornienko [Fri, 16 Jan 2015 15:57:15 +0000 (15:57 +0000)]
Attempt to fix the build with XCode 5.0.2 (and probably 5.1.1).

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

9 years agoAdd comdats to constructs and destructor in the microsoft abi.
Rafael Espindola [Fri, 16 Jan 2015 15:37:11 +0000 (15:37 +0000)]
Add comdats to constructs and destructor in the microsoft abi.

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

9 years agorestore fix for 18645, buildbot apparently gave a false positive.
Nathan Sidwell [Fri, 16 Jan 2015 15:20:14 +0000 (15:20 +0000)]
restore fix for 18645, buildbot apparently gave a false positive.
Correct logic concerning 'T &&' deduction against lvalues.

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

9 years ago[OPENMP] Fixed data-sharing attributes processing for variables with global
Alexey Bataev [Fri, 16 Jan 2015 07:11:33 +0000 (07:11 +0000)]
[OPENMP] Fixed data-sharing attributes processing for variables with global
storage.
This fix allows to use non-constant global variables, static local variables and static data
members in data-sharing attribute clauses in parallel and task regions.

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

9 years agoUse a trivial comdat for C++ tables.
Rafael Espindola [Thu, 15 Jan 2015 23:18:01 +0000 (23:18 +0000)]
Use a trivial comdat for C++ tables.

This produces comdats for vtables, typeinfo, typeinfo names, and vtts.

When combined with llvm not producing implicit comdats, not doing this would
cause code bloat on ELF and link errors on COFF.

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

9 years agoUse a trivial comdat for inline ctor/dtor when not using C5/D5.
Rafael Espindola [Thu, 15 Jan 2015 21:36:08 +0000 (21:36 +0000)]
Use a trivial comdat for inline ctor/dtor when not using C5/D5.

When combined with llvm not producing implicit comdats, not doing this would
cause code bloat on ELF and link errors on COFF.

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

9 years ago[PowerPC] Add a target option for invariant function descriptors
Hal Finkel [Thu, 15 Jan 2015 21:22:22 +0000 (21:22 +0000)]
[PowerPC] Add a target option for invariant function descriptors

The PPC backend will now assume that PPC64 ELFv1 function descriptors are
invariant. This must be true for well-defined C/C++ code, but I'm providing an
option to disable this assumption in case someone's JIT-engine needs it.

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

9 years agoWarn about dllexported explicit class template instantiation declarations (PR22035)
Hans Wennborg [Thu, 15 Jan 2015 21:18:30 +0000 (21:18 +0000)]
Warn about dllexported explicit class template instantiation declarations (PR22035)

Clang would previously become confused and crash here.

It does not make a lot of sense to export these, so warning seems appropriate.

MSVC will export some member functions for this kind of specializations, whereas
MinGW ignores the dllexport-edness. The latter behaviour seems better.

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

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

9 years agoPR 20146
Nathan Sidwell [Thu, 15 Jan 2015 16:45:53 +0000 (16:45 +0000)]
PR 20146
reject CV void return type on C definitions per 6.9.1/3

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

9 years ago[PM] Track an LLVM API update which separates the TargetLibraryInfo
Chandler Carruth [Thu, 15 Jan 2015 10:42:26 +0000 (10:42 +0000)]
[PM] Track an LLVM API update which separates the TargetLibraryInfo
object from the pass that provides access to it.

We should probably refactor the createTLI code here in Clang in light of
the new structure, but I wanted this patch to be a minimal one that just
patches the behavior back together.

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

9 years agoAST: alignof might be dependent because of alignment attributes
David Majnemer [Thu, 15 Jan 2015 10:04:14 +0000 (10:04 +0000)]
AST: alignof might be dependent because of alignment attributes

Dependent alignment attributes should make an alignof expression
dependent as well.

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

9 years ago[CMake] clangCodeGen: Prune a redundant "Target" out of libdeps. It is supplied by...
NAKAMURA Takumi [Thu, 15 Jan 2015 08:51:01 +0000 (08:51 +0000)]
[CMake] clangCodeGen: Prune a redundant "Target" out of libdeps. It is supplied by Analysis.

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

9 years agoAST: Ensure implicit records have default visibility
David Majnemer [Thu, 15 Jan 2015 08:41:25 +0000 (08:41 +0000)]
AST: Ensure implicit records have default visibility

Types composed with certain implicit record types would have their RTTI
marked as hidden because the implicit record type didn't have any
visibility.

This manifests itself as triggering false positives from tools like
clang's -fsantize=function feature.  The RTTI for a function type's
return type wouldn't match if the return type was an implicit record
type.

Patch by Stephan Bergmann!

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

9 years ago[CMake] Update libdeps on clangCodeGen, corresponding to r226079.
NAKAMURA Takumi [Thu, 15 Jan 2015 07:28:53 +0000 (07:28 +0000)]
[CMake] Update libdeps on clangCodeGen, corresponding to r226079.

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

9 years ago[Mips] Define macros `__mips_isa_rev` in case of mips32r6/mips64r6 options
Simon Atanasyan [Thu, 15 Jan 2015 07:04:48 +0000 (07:04 +0000)]
[Mips] Define macros `__mips_isa_rev` in case of mips32r6/mips64r6 options

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

9 years agoSema: Recover when a function template is in an extern "C" block
David Majnemer [Thu, 15 Jan 2015 07:04:38 +0000 (07:04 +0000)]
Sema: Recover when a function template is in an extern "C" block

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

9 years agoRemove unused parameter, followup to r179639. No behavior change.
Nico Weber [Thu, 15 Jan 2015 06:00:15 +0000 (06:00 +0000)]
Remove unused parameter, followup to r179639. No behavior change.

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

9 years agoRemove ASTConsumer::HandleVTable()'s bool parameter.
Nico Weber [Thu, 15 Jan 2015 04:07:35 +0000 (04:07 +0000)]
Remove ASTConsumer::HandleVTable()'s bool parameter.

Sema calls HandleVTable() with a bool parameter which is then threaded through
three layers.  The only effect of this bool is an early return at the last
layer.

Instead, remove this parameter and call HandleVTable() only if the bool is
true.  No intended behavior change.

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

9 years agoPR13699: Include friend declarations in code completion results if they had a
Richard Smith [Thu, 15 Jan 2015 02:27:20 +0000 (02:27 +0000)]
PR13699: Include friend declarations in code completion results if they had a
prior visible declaration. Prefer to take template parameter names from the
first declaration.

Testcase from a patch by Francisco Lopes!

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

9 years ago[PM] Update for LLVM r226078 which moved TargetLibraryInfo to the
Chandler Carruth [Thu, 15 Jan 2015 02:16:55 +0000 (02:16 +0000)]
[PM] Update for LLVM r226078 which moved TargetLibraryInfo to the
Analysis library.

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

9 years agoFix crash-on-invalid and name lookup when recovering from ~X::X() typo.
Richard Smith [Thu, 15 Jan 2015 00:48:52 +0000 (00:48 +0000)]
Fix crash-on-invalid and name lookup when recovering from ~X::X() typo.

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

9 years agoIR: Move MDLocation into place (clang testcases)
Duncan P. N. Exon Smith [Wed, 14 Jan 2015 22:28:03 +0000 (22:28 +0000)]
IR: Move MDLocation into place (clang testcases)

Update testcases to match LLVM change in r226048.

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

9 years agoRevert "More robust deployment target parsing on darwin"
Steven Wu [Wed, 14 Jan 2015 18:22:29 +0000 (18:22 +0000)]
Revert "More robust deployment target parsing on darwin"

This breaks green-dragon. Revert it and investigate.

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

9 years agodocs/conf.py: update for 3.7
Hans Wennborg [Wed, 14 Jan 2015 18:14:05 +0000 (18:14 +0000)]
docs/conf.py: update for 3.7

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

9 years agoReleaseNotes.rst: update to 3.7
Hans Wennborg [Wed, 14 Jan 2015 18:14:03 +0000 (18:14 +0000)]
ReleaseNotes.rst: update to 3.7

The 3.6 release notes are in the 3.6 branch.

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

9 years agoUpdate cxx_dr_status.html after 3.6 branch
Hans Wennborg [Wed, 14 Jan 2015 18:14:00 +0000 (18:14 +0000)]
Update cxx_dr_status.html after 3.6 branch

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

9 years agoMore robust deployment target parsing on darwin
Steven Wu [Wed, 14 Jan 2015 18:01:27 +0000 (18:01 +0000)]
More robust deployment target parsing on darwin

Summary:
This is a more robust way of figuring out implicit deployment target
from isysroot. It also handles iphone simulator target.

Reviewers: bob.wilson, t.p.northover

Reviewed By: t.p.northover

Subscribers: t.p.northover, cfe-commits

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

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

9 years agoclang-format: Disable flag for Google's Java and Javascript styles.
Daniel Jasper [Wed, 14 Jan 2015 12:24:59 +0000 (12:24 +0000)]
clang-format: Disable flag for Google's Java and Javascript styles.

Disable AlwaysBreakBeforeMultilineString, as the style guides don't
really say to do so.

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

9 years ago[mips] Handle transparent unions correctly.
Daniel Sanders [Wed, 14 Jan 2015 12:00:12 +0000 (12:00 +0000)]
[mips] Handle transparent unions correctly.

Summary:
This fixes MultiSource/Applications/lemon on big-endian N32 by correcting the
handling of the argument to wait(). glibc defines it as a transparent union of
void* and int*. Such unions are passed according to the rules of the first
member so the argument must be passed as if it were a void* (sign extended from
i32 to i64) and not as a union (shifted to the upper bits of an i64).

wait() already behaves correctly on big-endian O32 and N64 since the union is
already the same size as an argument slot.

Reviewers: atanasyan

Reviewed By: atanasyan

Subscribers: cfe-commits

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

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

9 years ago[cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.py
Chandler Carruth [Wed, 14 Jan 2015 11:29:14 +0000 (11:29 +0000)]
[cleanup] Re-sort *all* #include lines with llvm/utils/sort_includes.py

Sorry for the noise, I managed to miss a bunch of recent regressions of
include orderings here. This should actually sort all the includes for
Clang. Again, no functionality changed, this is just a mechanical
cleanup that I try to run periodically to keep the #include lines as
regular as possible across the project.

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

9 years ago[cleanup] Re-sort the #include lines using llvm/utils/sort_includes.py
Chandler Carruth [Wed, 14 Jan 2015 11:23:58 +0000 (11:23 +0000)]
[cleanup] Re-sort the #include lines using llvm/utils/sort_includes.py

No functionality changed, this is a purely mechanical cleanup to ensure
the #include order remains consistent across the project.

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

9 years agoclang-format: [Java] Support try blocks with resources.
Daniel Jasper [Wed, 14 Jan 2015 10:48:41 +0000 (10:48 +0000)]
clang-format: [Java] Support try blocks with resources.

Before:
  try
    (SomeResource rs = someFunction()) {
      Something();
    }

After:
  try (SomeResource rs = someFunction()) {
    Something();
  }

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

9 years agoclang-format: [Java] Prefer not to break in parameter annotations.
Daniel Jasper [Wed, 14 Jan 2015 10:36:31 +0000 (10:36 +0000)]
clang-format: [Java] Prefer not to break in parameter annotations.

Before:
  boolean someFunction(@Param(aaaaaaaaaaaaaaaa)
                       String aaaaa,
      String bbbbbbbbbbbbbbb) {}

After:
  boolean someFunction(
      @Param(aaaaaaaaaaaaaaaa) String aaaaa,
      String bbbbbbbbbbbbbbb) {}

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

9 years agoclang-format: [Java] Understand "import static".
Daniel Jasper [Wed, 14 Jan 2015 10:02:49 +0000 (10:02 +0000)]
clang-format: [Java] Understand "import static".

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

9 years agoclang-format: [Java] Don't let annotations confuse return type analysis.
Daniel Jasper [Wed, 14 Jan 2015 10:00:20 +0000 (10:00 +0000)]
clang-format: [Java] Don't let annotations confuse return type analysis.

Before:
  @Test
  ReturnType
  doSomething(String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}

After:
  @Test
  ReturnType doSomething(
      String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}

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

9 years agoclang-format: [Java] Don't line-wrap before annotations' l_parens.
Daniel Jasper [Wed, 14 Jan 2015 09:51:32 +0000 (09:51 +0000)]
clang-format: [Java] Don't line-wrap before annotations' l_parens.

Before:
  @SomeAnnotation
  (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
  int i;

After:
  @SomeAnnotation(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
  int i;

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

9 years agoclang-format: [Java] Don't get confused by leading annotations.
Daniel Jasper [Wed, 14 Jan 2015 09:47:57 +0000 (09:47 +0000)]
clang-format: [Java] Don't get confused by leading annotations.

Before:
  @Test(a)
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaa);

After:
  @Test(a)
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa);

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

9 years agoThe assembler is now enabled by default.
Brad Smith [Wed, 14 Jan 2015 08:23:49 +0000 (08:23 +0000)]
The assembler is now enabled by default.

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

9 years agoSema: It's cheaper to ask LookupResult::empty than to calculate linkage
David Majnemer [Wed, 14 Jan 2015 08:08:52 +0000 (08:08 +0000)]
Sema: It's cheaper to ask LookupResult::empty than to calculate linkage

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

9 years agoUse the integrated assembler by default on 32-bit PowerPC and SPARC.
Brad Smith [Wed, 14 Jan 2015 07:55:36 +0000 (07:55 +0000)]
Use the integrated assembler by default on 32-bit PowerPC and SPARC.

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

9 years agoReapply r225000 (reverted in r225555): DebugInfo: Generalize debug info location...
David Blaikie [Wed, 14 Jan 2015 07:38:27 +0000 (07:38 +0000)]
Reapply r225000 (reverted in r225555): DebugInfo: Generalize debug info location handling (and follow-up commits).

Several pieces of code were relying on implicit debug location setting
which usually lead to incorrect line information anyway. So I've fixed
those (in r225955 and r225845) separately which should pave the way for
this commit to be cleanly reapplied.

The reason these implicit dependencies resulted in crashes with this
patch is that the debug location would no longer implicitly leak from
one place to another, but be set back to invalid. Once a call with
no/invalid location was emitted, if that call was ever inlined it could
produce invalid debugloc chains and assert during LLVM's codegen.

There may be further cases of such bugs in this patch - they're hard to
flush out with regression testing, so I'll keep an eye out for reports
and investigate/fix them ASAP if they come up.

Original commit message:

Reapply "DebugInfo: Generalize debug info location handling"

Originally committed in r224385 and reverted in r224441 due to concerns
this change might've introduced a crash. Turns out this change fixes the
crash introduced by one of my earlier more specific location handling
changes (those specific fixes are reverted by this patch, in favor of
the more general solution).

Recommitted in r224941 and reverted in r224970 after it caused a crash
when building compiler-rt. Looks to be due to this change zeroing out
the debug location when emitting default arguments (which were meant to
inherit their outer expression's location) thus creating call
instructions without locations - these create problems for inlining and
must not be created. That is fixed and tested in this version of the
change.

Original commit message:

This is a more scalable (fixed in mostly one place, rather than many
places that will need constant improvement/maintenance) solution to
several commits I've made recently to increase source fidelity for
subexpressions.

This resetting had to be done at the DebugLoc level (not the
SourceLocation level) to preserve scoping information (if the resetting
was done with CGDebugInfo::EmitLocation, it would've caused the tail end
of an expression's codegen to end up in a potentially different scope
than the start, even though it was at the same source location). The
drawback to this is that it might leave CGDebugInfo out of sync. Ideally
CGDebugInfo shouldn't have a duplicate sense of the current
SourceLocation, but for now it seems it does... - I don't think I'm
going to tackle removing that just now.

I expect this'll probably cause some more buildbot fallout & I'll
investigate that as it comes up.

Also these sort of improvements might be starting to show a weakness/bug
in LLVM's line table handling: we don't correctly emit is_stmt for
statements, we just put it on every line table entry. This means one
statement split over multiple lines appears as multiple 'statements' and
two statements on one line (without column info) are treated as one
statement.

I don't think we have any IR representation of statements that would
help us distinguish these cases and identify the beginning of each
statement - so that might be something we need to add (possibly to the
lexical scope chain - a scope for each statement). This does cause some
problems for GDB and possibly other DWARF consumers.

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

9 years agoDebugInof: Correct the location of exception cleanups in global ctors/dtors and ObjC...
David Blaikie [Wed, 14 Jan 2015 07:10:46 +0000 (07:10 +0000)]
DebugInof: Correct the location of exception cleanups in global ctors/dtors and ObjC methods

Without setting the CurEHLocation these cleanups would be attributed to
whatever the last active debug line location was (the 'fn' call in the
included test cases). By setting CurEHLocation correctly the line
information is improved/corrected.

This quality bug turned into a crasher with r225000 when, instead of
allowing the last location to persist, it would be zero'd out. This
could lead to a function call (such as the dtor) being made without a
debug location - if that call was subsequently inlined (and the caller
and callee had debug info, just not the call instruction) the inliner
would violate important constraints about the debug location chains by
not updating the inlined instructions to chain up to the callee
locations.

So, by fixing this bug, I am addressing the assertion failures
introduced by r225000 and should be able to recommit that patch with
impunity...

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

9 years agoRevert "Insert random noops to increase security against ROP attacks (clang)"
JF Bastien [Wed, 14 Jan 2015 05:24:11 +0000 (05:24 +0000)]
Revert "Insert random noops to increase security against ROP attacks (clang)"

This reverts commit:
http://reviews.llvm.org/D3393

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

9 years agoSema: Relax parsing of '#' in constraints
David Majnemer [Wed, 14 Jan 2015 05:11:09 +0000 (05:11 +0000)]
Sema: Relax parsing of '#' in constraints

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

9 years agoSema: Check type compatibility with the most recent decl when merging
David Majnemer [Wed, 14 Jan 2015 02:27:38 +0000 (02:27 +0000)]
Sema: Check type compatibility with the most recent decl when merging

We would check the type information from the declaration found by lookup
but we would neglect checking compatibility with the most recent
declaration.  This would make it possible for us to not correctly
diagnose inconsistencies with declarations which were made in a
different scope.

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

9 years ago[AVX512] Add FP unpack intrinsics
Adam Nemet [Wed, 14 Jan 2015 01:31:17 +0000 (01:31 +0000)]
[AVX512] Add FP unpack intrinsics

These are implemented with __builtin_shufflevector just like AVX.

We have some tests on the LLVM side to assert that these shufflevectors do
indeed generate the corresponding unpck instruction.

Part of <rdar://problem/17688758>

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

9 years agoInsert random noops to increase security against ROP attacks (clang)
JF Bastien [Wed, 14 Jan 2015 01:07:51 +0000 (01:07 +0000)]
Insert random noops to increase security against ROP attacks (clang)

A pass that adds random noops to X86 binaries to introduce diversity with the goal of increasing security against most return-oriented programming attacks.

Command line options:
  -noop-insertion // Enable noop insertion.
  -noop-insertion-percentage=X // X% of assembly instructions will have a noop prepended (default: 50%, requires -noop-insertion)
  -max-noops-per-instruction=X // Randomly generate X noops per instruction. ie. roll the dice X times with probability set above (default: 1). This doesn't guarantee X noop instructions.

In addition, the following 'quick switch' in clang enables basic diversity using default settings (currently: noop insertion and schedule randomization; it is intended to be extended in the future).
  -fdiversify

This is the clang part of the patch.
llvm part: D3392

http://reviews.llvm.org/D3393
Patch by Stephen Crane (@rinon)

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

9 years agoUpdate HelpText for -fsanitize= option.
Alexey Samsonov [Wed, 14 Jan 2015 00:51:17 +0000 (00:51 +0000)]
Update HelpText for -fsanitize= option.

There are too many available sanitizers now - redirect to
user manual instead of listing them all.

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

9 years agoUpdate for move in llvm.
Eric Christopher [Wed, 14 Jan 2015 00:50:32 +0000 (00:50 +0000)]
Update for move in llvm.

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

9 years agoLook through sugar when determining whether a type is a scoped enumeration
Richard Smith [Wed, 14 Jan 2015 00:33:10 +0000 (00:33 +0000)]
Look through sugar when determining whether a type is a scoped enumeration
type. Patch by Stephan Bergmann!

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

9 years agoSema: An extern declaration can't be a redeclaration of a parameter
David Majnemer [Wed, 14 Jan 2015 00:31:13 +0000 (00:31 +0000)]
Sema: An extern declaration can't be a redeclaration of a parameter

In the following:
void f(int x) { extern int x; }

The second declaration of 'x' shouldn't be considered a redeclaration of
the parameter.

This is a different approach to r225780.

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

9 years agoSink a parameter into the callee since it's always the same expression in terms of...
David Blaikie [Wed, 14 Jan 2015 00:04:42 +0000 (00:04 +0000)]
Sink a parameter into the callee since it's always the same expression in terms of another parameter

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

9 years agoDebugInfo: Correct the location of EH cleanup for blocks
David Blaikie [Tue, 13 Jan 2015 23:06:27 +0000 (23:06 +0000)]
DebugInfo: Correct the location of EH cleanup for blocks

This was previously piggybacking on whatever happened to be the last
location set on CGDebugInfo/DIBuilder, which was wrong (it was often the
current location, such as the 'fn()' call site, not the end of the
block). With my improvements to set/unset the location in a scoped
manner (r225000) this went from a bad quality situation, to a crash.
Fixing this goes part-way to unblocking the recommit of r225000.

It's likely that any call to CodeGenFunction::StartFunction without the
CurEHLocation set represents a similar bug or risk of a bug. Perhaps
there are some callers that know they won't generate EH cleanups, but
I'm not sure.

I considered a generic catch-fix in StartFunction (just fallback to the
GlobalDecl's location) but that seemed like it'd mask bugs where the EH
location shouldn't be the same as the decl's location (& indeed by not
using that stop-gap I found this bug). We'll see how long I can hold out
on the generic catch-all. I might eventually be able to add an assertion
in.

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

9 years agoclang-format: [Java] Detect `native` keyword.
Nico Weber [Tue, 13 Jan 2015 22:32:50 +0000 (22:32 +0000)]
clang-format: [Java] Detect `native` keyword.

Before:
  public native<X> Foo foo();

After:
  public native <X> Foo foo();

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

9 years agoAdd [extern_c] attribute to _Builtin_intrinsics module
Ben Langmuir [Tue, 13 Jan 2015 21:54:32 +0000 (21:54 +0000)]
Add [extern_c] attribute to _Builtin_intrinsics module

This allows users to import this module inside an extern "C" {} block.

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

9 years agoMention FreeBSD support.
Roman Divacky [Tue, 13 Jan 2015 21:31:03 +0000 (21:31 +0000)]
Mention FreeBSD support.

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

9 years agoWhen attribute 'optnone' appears on the same declaration with a
Paul Robinson [Tue, 13 Jan 2015 18:34:56 +0000 (18:34 +0000)]
When attribute 'optnone' appears on the same declaration with a
conflicting attribute, warn about the conflict and pick a "winning"
attribute to preserve, instead of emitting an error.  This matches the
behavior when the conflicting attributes are on different declarations.

Along the way I discovered that conflicts involving __forceinline were
reported as 'always_inline' (alternate spelling, same attribute) so
fixed that up to report the attribute as spelled in the source.

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

9 years agoInherit attributes when infering a framework module
Ben Langmuir [Tue, 13 Jan 2015 17:47:44 +0000 (17:47 +0000)]
Inherit attributes when infering a framework module

If a module map contains
framework module * [extern_c] {}

We will now infer [extern_c] on the inferred framework modules (we
already inferred [system] as a special case).

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

9 years agoHandle [extern_c] attribute in module printer
Ben Langmuir [Tue, 13 Jan 2015 17:47:38 +0000 (17:47 +0000)]
Handle [extern_c] attribute in module printer

I'm not sure why we have OS.indent(Indent+2) for the system attribute,
but presumably we want the same behaviour for all attributes...

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

9 years agoRemove unused method canInferFrameworkModule
Ben Langmuir [Tue, 13 Jan 2015 17:47:29 +0000 (17:47 +0000)]
Remove unused method canInferFrameworkModule

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

9 years ago[mips] Fix va_arg() for pointer types on big-endian N32.
Daniel Sanders [Tue, 13 Jan 2015 10:47:00 +0000 (10:47 +0000)]
[mips] Fix va_arg() for pointer types on big-endian N32.

Summary:
The Mips ABI's treat pointers in the same way as integers. They are
sign-extended to 32-bit for O32, and 64-bit for N32/N64. This doesn't matter
for O32 and N64 where pointers are already the correct width but it does matter
for big-endian N32, where pointers are 32-bit and need promoting.

The caller side is already passing pointers correctly. This patch corrects the
callee.

Reviewers: vmedic, atanasyan

Reviewed By: atanasyan

Subscribers: cfe-commits

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

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

9 years agoRevert "Sema: An extern declaration can't be a redeclaration of a parameter"
David Majnemer [Tue, 13 Jan 2015 10:14:57 +0000 (10:14 +0000)]
Revert "Sema: An extern declaration can't be a redeclaration of a parameter"

This reverts commit r225780, we can't compile line 181 in
sanitizer_platform_limits_posix.cc with this commit.

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

9 years agoSema: An extern declaration can't be a redeclaration of a parameter
David Majnemer [Tue, 13 Jan 2015 09:55:56 +0000 (09:55 +0000)]
Sema: An extern declaration can't be a redeclaration of a parameter

In the following:
void f(int x) { extern int x; }

The second declaration of 'x' shouldn't be considered a redeclaration of
the parameter.

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

9 years agoUpdate clang-format.el to use xml output and patch in the returned chunks.
Manuel Klimek [Tue, 13 Jan 2015 08:35:34 +0000 (08:35 +0000)]
Update clang-format.el to use xml output and patch in the returned chunks.

This leads to better undo behavior and avoids window content jumping
around.

Patch by Johann Klähn.

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

9 years agoParse: Switch to using EOF tokens for late parsed attributes
David Majnemer [Tue, 13 Jan 2015 08:35:24 +0000 (08:35 +0000)]
Parse: Switch to using EOF tokens for late parsed attributes

The EOF token injection technique is preferable to using
isBeforeInTranslationUnit to determine whether or not additional cleanup
is needed.  I don't have an example off-hand that requires it but it is
nicer nonetheless.

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

9 years agoParse: Don't crash when default argument in typedef consists of sole '='
David Majnemer [Tue, 13 Jan 2015 07:42:33 +0000 (07:42 +0000)]
Parse: Don't crash when default argument in typedef consists of sole '='

We'd crash trying to make the SourceRange for the tokens we'd like to
highlight.  Don't assume there is more than one token makes up the
default argument.

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

9 years agoParse: Don't crash if missing an initializer expression
David Majnemer [Tue, 13 Jan 2015 05:28:24 +0000 (05:28 +0000)]
Parse: Don't crash if missing an initializer expression

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

9 years agoParse: use the EOF token method to lex inline method bodies
David Majnemer [Tue, 13 Jan 2015 05:06:20 +0000 (05:06 +0000)]
Parse: use the EOF token method to lex inline method bodies

Mark the end of the method body with an EOF token, collect it once we
expect to be done with method body parsing.  No functionality change
intended.

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

9 years agoParse: Further simplify ParseLexedMethodDeclaration
David Majnemer [Tue, 13 Jan 2015 04:20:57 +0000 (04:20 +0000)]
Parse: Further simplify ParseLexedMethodDeclaration

No functionality change intended, just moving code around to make it
simpler.

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

9 years agoMark vtable used on explicit destructor definitions.
Nico Weber [Tue, 13 Jan 2015 03:52:11 +0000 (03:52 +0000)]
Mark vtable used on explicit destructor definitions.

There are two things in a C++ program that need to read the vtable pointer:
Constructors and destructors.  (A few other operations -- virtual calls,
dynamic cast, rtti -- read the vtable pointer off a this pointer, but for
this they don't need the vtable symbol.)  Implicit constructors and destructors
and explicit constructors already marked the vtable as used, but explicit
destructors didn't.

Note that the only thing sema's "mark a class's vtable used" does is to mark all
final overriders of the class as referenced, it does _not_ cause emission of
the vtable itself.  This is done on demand by codegen, independent of sema,
since sema might emit functions that are not referenced.  (The exception are
vtables that are forced via key functions -- these are forced onto codegen
by sema.)

This bug went unnoticed for years because it doesn't have observable effects
(yet -- I want to change this in PR20337, which is why I noticed this).

r213109 made it so that _calls_ to constructors don't mark the vtable used.
Currently, _calls_ to destructors still mark the vtable used.  If that
wasn't the case, this program would tickle the problem:

  test.h:
    template <typename T>
    struct B {
      int* p;
      virtual ~B() { delete p; }
      virtual void f() {}
    };

    struct __attribute__((visibility("default"))) C {
      C();
      B<int> m;
    };

  test2.cc:
    #include "test.h"
    int main() {
      C* c = new C;
      delete c;
    }

  test3.cc:
    #include "test.h"
    C::C() {}

  # This bin/clang++ binary doesn't MarkVTableUsed() for virtual dtor calls:
  $ bin/clang++ -shared test3.cc -std=c++11 -O2  -fvisibility=hidden \
        -fvisibility-inlines-hidden  -o libtest3.dylib
  $ bin/clang++ test2.cc -std=c++11 -O2  -fvisibility=hidden \
        -fvisibility-inlines-hidden  libtest3.dylib
  Undefined symbols for architecture x86_64:
    "B<int>::f()", referenced from:
        vtable for B<int> in test2-af8f4f.o
  ld: symbol(s) not found for architecture x86_64

What's happening here is that there's a copy of B's vtable hidden in
libtest3.dylib, because C's constructor caused an implicit instantiation of that
(and implicit constructors generate vtables).
test2.cc calls C's destructDr, which destroys the B<int> member,
which wants to overwrite the vtable back to B (think of B as the base of a class
hierarchy, and of hierarchical destruction -- maybe we shouldn't do the vtable
writing in destructors of final classes), but there's nothing in test2.cc that
marks B's vtable used.  So codegen writes out the vtable, but since it wasn't
marked used, sema didn't mark all the virtual functions (in particular f())
as used.

Note that this change makes us reject programs we didn't reject before (see
the included Sema test case), but both gcc and cl also reject this code, and
clang used to reject it before r213109.

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

9 years ago[OPENMP] Consider global named register variables as threadprivate by default.
Alexey Bataev [Tue, 13 Jan 2015 03:35:30 +0000 (03:35 +0000)]
[OPENMP] Consider global named register variables as threadprivate by default.
Register are thread-local by default, so we have to consider them as threadprivate.

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

9 years agoExtend the self move warning to record types.
Richard Trieu [Tue, 13 Jan 2015 02:32:02 +0000 (02:32 +0000)]
Extend the self move warning to record types.

Move the logic for checking self moves into SemaChecking and add that function
to Sema since it is now used in multiple places.

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

9 years agoIf we don't find a matching ) for a ( in an exception specification, keep the tokens...
Richard Smith [Tue, 13 Jan 2015 02:24:58 +0000 (02:24 +0000)]
If we don't find a matching ) for a ( in an exception specification, keep the tokens around so we can diagnose an error rather than silently discarding them.

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

9 years agoPR22208: On FreeBSD systems, __STDC_MB_MIGHT_NEQ_WC__ is expected to be defined
Richard Smith [Tue, 13 Jan 2015 01:47:45 +0000 (01:47 +0000)]
PR22208: On FreeBSD systems, __STDC_MB_MIGHT_NEQ_WC__ is expected to be defined
even though every basic source character literal has the same numerical value
as a narrow or wide character literal.

It appears that the FreeBSD folks are trying to use this macro to mean
something other than what the relevant standards say it means, but their usage
is conforming, so put up with it.

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

9 years agoSimplify a test. No behavior change.
Nico Weber [Tue, 13 Jan 2015 00:24:46 +0000 (00:24 +0000)]
Simplify a test. No behavior change.

Templates don't have key functions (cf computeKeyFunction() in
RecordLayoutBuilder.cpp), so don't have something that looks like one.

Also, instead of a vcall to force generation of the vtable, just construct
the object.  This is how the repro on PR5557 (what the test is for) worked too.

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

9 years agoReimplement -fsanitize-recover family of flags.
Alexey Samsonov [Mon, 12 Jan 2015 22:39:12 +0000 (22:39 +0000)]
Reimplement -fsanitize-recover family of flags.

Introduce the following -fsanitize-recover flags:
  - -fsanitize-recover=<list>: Enable recovery for selected checks or
      group of checks. It is forbidden to explicitly list unrecoverable
      sanitizers here (that is, "address", "unreachable", "return").
  - -fno-sanitize-recover=<list>: Disable recovery for selected checks or
     group of checks.
  - -f(no-)?sanitize-recover is now a synonym for
    -f(no-)?sanitize-recover=undefined,integer and will soon be deprecated.

These flags are parsed left to right, and mask of "recoverable"
sanitizer is updated accordingly, much like what we do for -fsanitize= flags.
-fsanitize= and -fsanitize-recover= flag families are independent.

CodeGen change: If there is a single UBSan handler function, responsible
for implementing multiple checks, which have different recoverable setting,
then we emit two handler calls instead of one:
the first one for the set of "unrecoverable" checks, another one - for
set of "recoverable" checks. If all checks implemented by a handler have the
same recoverability setting, then the generated code will be the same.

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

9 years ago[patch][pr19848] Produce explicit comdats in clang.
Rafael Espindola [Mon, 12 Jan 2015 22:13:53 +0000 (22:13 +0000)]
[patch][pr19848] Produce explicit comdats in clang.

The llvm IR until recently had no support for comdats. This was a problem when
targeting C++ on ELF/COFF as just using weak linkage would cause quite a bit of
dead bits to remain on the executable (unless -ffunction-sections,
-fdata-sections and --gc-sections were used).

To fix the problem, llvm's codegen will just assume that any weak or linkonce
that is not in an explicit comdat should be output in one with the same name as
the global.

This unfortunately breaks cases like pr19848 where a weak symbol is not
xpected to be part of any comdat.

Now that we have explicit comdats in the IR, we can finally get both cases
right.

This first patch just makes clang give explicit comdats to GlobalValues where
t is allowed to.

A followup patch to llvm will then stop implicitly producing comdats.

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

9 years agoWrap to 80 columns. No behavior change.
Nico Weber [Mon, 12 Jan 2015 21:24:10 +0000 (21:24 +0000)]
Wrap to 80 columns. No behavior change.

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

9 years agoDon't use a doc comment in a function body.
Nico Weber [Mon, 12 Jan 2015 21:22:27 +0000 (21:22 +0000)]
Don't use a doc comment in a function body.

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

9 years agoreverting due to build bot failure
Nathan Sidwell [Mon, 12 Jan 2015 20:13:20 +0000 (20:13 +0000)]
reverting due to build bot failure

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