Commit Graph

22064 Commits

Author SHA1 Message Date
Douglas Gregor 60060d6f8f Treat the Microsoft/Borland keyword "__except" as a context-sensitive
keyword, because both libstdc++ and libc++ use "__except" as an
identifier. Fixes <rdar://problem/10322555>.

llvm-svn: 142636
2011-10-21 03:57:52 +00:00
Sean Callanan 95e74be193 I added a new function to DeclContext called
addDeclInternal().  This function suppresses any
calls to FindExternalVisibleDeclsByName() while
a Decl is added to a DeclContext.  This behavior
is required for the ASTImporter, because in the
case of the LLDB client the ASTImporter would be
called recursively to import the visible decls,
which leads to assertions because the recursive
call is seeing partially-formed types.

I also modified the ASTImporter to use
addDeclInternal() in all places where it would
otherwise use addDecl().  This fix should not
affect the rest of Clang, passes Clang's
testsuite, and fixes several serious LLDB bugs.

llvm-svn: 142634
2011-10-21 02:57:43 +00:00
Nick Lewycky ba743b75cb Take DW_AT_comp_dir from $PWD when it's present and starts with a '/'. This is
closer to what GCC does, except that GCC also checks that the inodes for $PWD
and '.' match.

llvm-svn: 142633
2011-10-21 02:32:14 +00:00
Richard Smith fe2750db42 Add -Wc++98-compat diagnostics for jumps which bypass initialization of non-POD
but trivially constructible and destructible variables in C++11 mode. Also
incidentally improve the precision of the wording for jump diagnostics in C++98
mode.

llvm-svn: 142619
2011-10-20 21:42:12 +00:00
Douglas Gregor 7f4fbecbe2 When fixing up the storage class for an anonymous union, don't mark
the anonymous union as valid: our fixes have Fix-Its.

llvm-svn: 142616
2011-10-20 20:40:00 +00:00
Richard Smith f411196d15 'extern template' is a C++11 feature. Add an Extension for C++98 (this matches
gcc's behaviour), and a -Wc++98-compat-pedantic warning for C++11.

llvm-svn: 142597
2011-10-20 18:35:58 +00:00
Douglas Gregor f4ef4d2ec5 There's no point in marking a declaration invalid just because it
shadows a template parameter. Complain about the shadowing (or not,
under -fms-extensions), but don't invalidate the declaration. Merely
forget about the template parameter declaration.

llvm-svn: 142596
2011-10-20 17:58:49 +00:00
Douglas Gregor 44e5a0a72b Diagnose class template (partial) specializations that occur in the
*wrong* class scope. This is one of the problems behind
<rdar://problem/9676205>.

llvm-svn: 142588
2011-10-20 16:41:18 +00:00
Douglas Gregor f65d8ffca7 When we parse something that looks like a templated friend tag but
actually just has an extraneous 'template<>' header, strip off the
'template<>' header and treat it as a normal friend tag. Fixes PR10660
/ <rdar://problem/9958322>.

llvm-svn: 142587
2011-10-20 15:58:54 +00:00
Ted Kremenek 337c5b880c Further refine the diagnostic categories for ARC diagnostics. Addresses <rdar://problem/10245086>.
llvm-svn: 142571
2011-10-20 05:07:47 +00:00
Richard Smith 91c7bbde4b Add -Wc++98-compat warning for enumerations in nested name specifiers.
llvm-svn: 142568
2011-10-20 03:28:47 +00:00
David Blaikie 733f7bb81f FixIt insert 'static' for anonymous unions at global or namespace scope.
llvm-svn: 142566
2011-10-20 02:49:08 +00:00
David Blaikie 6f686fc271 Add a fixit to remove storage specifiers on anonymous enums.
llvm-svn: 142565
2011-10-20 02:10:55 +00:00
Eli Friedman 7bba3ef862 Define __STDC__ in -fms-extensions mode; defining it is consistent with gcc, and not defining it causes the system headers on multiple platforms to break with -fms-extensions because they assume the lack of a definition of __STDC__ implies a traditional (pre-ANSI) preprocessor. PR10324 and <rdar://problem/10313809> .
llvm-svn: 142554
2011-10-19 23:46:05 +00:00
David Blaikie 30d15445ed 80 cols (one I created in my last commit, plus a bunch of others that were already there)
llvm-svn: 142552
2011-10-19 22:56:21 +00:00
David Blaikie 0a8e8999d6 Don't provide errors for anonymous unions when they're actually anonymous classes.
llvm-svn: 142551
2011-10-19 22:43:29 +00:00
Richard Smith 09f76ee63c Improve the diagnostic when a comma ends up at the end of a declarator group
instead of a semicolon (as sometimes happens during refactorings). When such a
comma is seen at the end of a line, and is followed by something which can't
possibly be a declarator (or even something which might be a plausible typo for
a declarator), suggest that a semicolon was intended.

llvm-svn: 142544
2011-10-19 21:33:05 +00:00
Richard Smith f720df0ed6 -Wc++98-compat: warn on nontrivial types used in unions and anonymous structs.
llvm-svn: 142541
2011-10-19 20:41:51 +00:00
Matt Beaumont-Gay 4b489fa629 Only warn at self-initialization if some later use is always uninitialized.
llvm-svn: 142538
2011-10-19 18:53:03 +00:00
Richard Smith c620f554b9 -Wc++98-compat: diagnose if a reference is bound to a prvalue which does not
have an unambiguous accessible copying constructor; this is ill-formed in C++98.

llvm-svn: 142533
2011-10-19 16:55:56 +00:00
Douglas Gregor e248eea214 Improve the warning for cv-qualifiers on free functions, from Ahmed Charles!
llvm-svn: 142478
2011-10-19 06:04:55 +00:00
David Blaikie 651c73ce78 Fix pr9789, assert-on-invalid while instantiating an (invalid) class template with a non-final parameter pack. Also improve the warning for non-final parameter packs in this scenario so it only fires once, rather than once for every template parameter after the non-final parameter pack.
llvm-svn: 142473
2011-10-19 05:19:50 +00:00
Argyrios Kyrtzidis 4e8b13613b Don't forget to complete the objc interface before asking for information,
otherwise lldb will suffer.

llvm-svn: 142471
2011-10-19 02:25:16 +00:00
Richard Smith a066ccfcf1 Add a -Wc++98-compat warning for friend functions of class templates which would
be implicitly instantiated (resulting in a redefinition) in C++98.

llvm-svn: 142468
2011-10-19 00:54:10 +00:00
Eric Christopher 7ec8ec8581 Add block information for ObjC @catch blocks.
Fixes rdar://10282889

llvm-svn: 142467
2011-10-19 00:44:01 +00:00
Eric Christopher a9d3497b5e Add a new subclass of RunCleanupScopes that also handles creating new
lexical blocks for debug info.

llvm-svn: 142466
2011-10-19 00:43:52 +00:00
Peter Collingbourne a48f33f951 Move static array parameter checks to SemaExpr, per Doug's request
llvm-svn: 142465
2011-10-19 00:16:45 +00:00
Richard Smith 38c0e0417c -Wc++98-compat: warn if a SFINAE substitution in C++11 suppresses an access
control diagnostic.

llvm-svn: 142463
2011-10-19 00:07:01 +00:00
Fariborz Jahanian 7f73302b4f objc: allow class name qualified with protocols in
iboutletcollection attribute. But ignore protocol
list. // rdar://10296078

llvm-svn: 142459
2011-10-18 23:13:50 +00:00
Anna Zaks d009bfac0c [analyzer] Move predecessor into the NodeBuilder context.
llvm-svn: 142454
2011-10-18 23:06:48 +00:00
Anna Zaks a99b41f37f [analyzer] Make NodeBuilder and Pred node loosely coupled
NodeBuilder should not assume it's dealing with a single predecessor. Remove predecessor getters. Modify the BranchNodeBuilder to not be responsible for doing auto-transitions (which depend on a predecessor).

llvm-svn: 142453
2011-10-18 23:06:44 +00:00
Anna Zaks 1dd965eaa5 [analyzer] Remove StmtNodeBuilder from CheckerContext
It now only depends on a generic NodeBuilder instead. As part of this change, make the generic node builder results finalized by default.

llvm-svn: 142452
2011-10-18 23:06:38 +00:00
Anna Zaks 88d9462b73 [analyzer] Subclassing StmtBuilder from the NodeBuilder
llvm-svn: 142451
2011-10-18 23:06:33 +00:00
Anna Zaks e83ddcc4ec [analyzer] Remove dead code.
ExprEngineBuilders is not used.

llvm-svn: 142450
2011-10-18 23:06:29 +00:00
Anna Zaks 6d285c58ec [analyzer] Modularize builder use in processBranch.
Take advantage of the new builders for branch processing. As part of this change pass generic NodeBuilder (instead of BranchNodeBuilder) to the BranchCondition callback and remove the unused methods form BranchBuilder.

llvm-svn: 142448
2011-10-18 23:06:21 +00:00
Anna Zaks eebbbc7253 [analyzer] Pull Pred out of NodeBuilderContext.
Each builder will have a different one, so it doesn't make sense to keep it in the context.

llvm-svn: 142447
2011-10-18 23:06:16 +00:00
Anna Zaks ce5e97efdd [analyzer] NodeBuilder Refactoring: Subclass BranchNodeBuilder from NodeBuilder.
llvm-svn: 142444
2011-10-18 23:06:04 +00:00
Anna Zaks fc0189aadc [analyzer] Node Builder refactoring: Introduce a simple Node Builder responsible for generating the node frontier.
Currently we have a bunch of different node builders which provide some common
functionality but are difficult to refactor. Each builder generates nodes of
different kinds and calculates the frontier nodes, which should be propagated
to the next step (after the builder dies).

Introduce a new NodeBuilder which provides very basic node generation facilities
but takes care of the second problem. The idea is that all the other builders
will eventually use it. Use this builder in CheckerContext instead of
StmtNodeBuilder (the way the frontier is propagated to the StmtBuilder
is a hack and will be removed later on).

llvm-svn: 142443
2011-10-18 23:05:58 +00:00
John McCall 59207978e6 More metaprogramming with builtin types.
llvm-svn: 142433
2011-10-18 22:28:37 +00:00
Richard Smith c82397332d -Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 2.
llvm-svn: 142426
2011-10-18 21:39:00 +00:00
Douglas Gregor e5c79d5ea8 Provide result types for code completions that describe built-in
expressions (this, sizeof, etc.).

llvm-svn: 142424
2011-10-18 21:20:17 +00:00
John McCall 91aee685d8 Add a __has_feature check for arc_cf_code_audited.
llvm-svn: 142423
2011-10-18 21:18:53 +00:00
John McCall e314e27c58 Macro metaprogramming for builtin types.
llvm-svn: 142420
2011-10-18 21:02:43 +00:00
Richard Smith 0bf8a492fd -Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 1.
llvm-svn: 142419
2011-10-18 20:49:44 +00:00
Daniel Dunbar b274318bba Frontend: Support -iframework.
llvm-svn: 142418
2011-10-18 20:40:38 +00:00
Richard Smith aed32b4d8c Simplify RecordDeclCXX::setBases slightly. No functional change.
Add test that a variadic base list which expands to 0 bases doesn't make the
class a non-aggregate. This test passed before the change, too.

llvm-svn: 142411
2011-10-18 20:08:55 +00:00
Fariborz Jahanian 2f31b33f34 objc: more changes in use of IBOutletCollection attribute.
'Class' is disallowed as argument.  If the argument is missing, 
NSObject is assumed. // rdar://10296078

llvm-svn: 142409
2011-10-18 19:54:31 +00:00
Argyrios Kyrtzidis 05c65fbdb6 [arcmt] Rewrite attributes in extensions as well. rdar://9992142
llvm-svn: 142407
2011-10-18 19:49:19 +00:00
Argyrios Kyrtzidis b51684d7a1 Set the objc "property attributes as written" for extension properties as well.
llvm-svn: 142406
2011-10-18 19:49:16 +00:00
Richard Smith c30493db3c In C++11, a class's members are allowed to be nominated as friends.
llvm-svn: 142393
2011-10-18 18:33:57 +00:00
Argyrios Kyrtzidis 058b451d87 [driver] Make the driver to link the simulator arclite lib when passing -mios-simulator-version-min.
rdar://10218700

llvm-svn: 142372
2011-10-18 17:40:15 +00:00
Fariborz Jahanian 6b70865ec0 objc: diagnose invalid argument to an
iboutletcollection attribute intead of crashing.
// rdar://10296078

llvm-svn: 142364
2011-10-18 17:11:10 +00:00
Douglas Gregor 09deffa067 Make it possible to compute the type of 'this' without capturing
it. Refactoring to be used in a moment.

llvm-svn: 142360
2011-10-18 16:47:30 +00:00
Douglas Gregor 4205feffcd Add code completions for C++0x expressions
llvm-svn: 142357
2011-10-18 16:29:03 +00:00
Benjamin Kramer 80ca407610 Use llvm::Triple's methods to parse FreeBSD version numbers.
Who could've thought that FreeBSD would ever reach version 10!
Patch from Dimitry Andric.

llvm-svn: 142349
2011-10-18 10:10:08 +00:00
Hans Wennborg f99d04f841 Suggest %zu for size_t args to printf.
For PR11152. Make PrintSpecifier::fixType() suggest "%zu" for size_t, etc.
rather than looking at the underlying type and suggesting "%llu" or other
platform-specific length modifiers. Applies to C99 and C++11.

llvm-svn: 142342
2011-10-18 08:10:06 +00:00
Douglas Gregor d793e7c3f7 Don't format the code completion for parameters of block literal
arguments as block literal arguments; the block literal argument code
completion should only go one level deep. Fixes <rdar://problem/10291294>.

llvm-svn: 142335
2011-10-18 04:23:19 +00:00
Richard Smith 83c19296ff Add -Wc++11-compat warning for an inline specifier on an explicit instantiation.
llvm-svn: 142333
2011-10-18 03:44:03 +00:00
Douglas Gregor f333f8c40d When transforming the arguments for a C++ "new" expression, make sure
to drop the implicitly-generated value initialization expression used
for initializing scalars. Fixes <rdar://problem/10283928>.

llvm-svn: 142330
2011-10-18 02:43:19 +00:00
Richard Smith 050d261ec7 Refactor the checking for explicit template instantiations being performed in
the right namespace in C++11 mode. Teach the code to prefer the 'must be in
precisely this namespace' diagnostic whenever that's true, and fix a defect
which resulted in the -Wc++11-compat warning in C++98 mode sometimes being
omitted.

llvm-svn: 142329
2011-10-18 02:28:33 +00:00
John McCall 43d4dd49bf Argyrios says this change is required for safety under PTH.
Me, I believe him.

llvm-svn: 142327
2011-10-18 01:36:41 +00:00
Eli Friedman 66005df1f1 Revert accidental commit.
llvm-svn: 142326
2011-10-18 01:18:41 +00:00
Eli Friedman 5e9534b0ae Rewrite parts of MS ABI C++ layout. Based on work by r4start; I ended up doing this while I was trying to review his patch.
llvm-svn: 142325
2011-10-18 00:55:28 +00:00
John McCall 95ff270ee9 Fix several bugs with #pragma clang arc_cf_code_audited and macros.
llvm-svn: 142324
2011-10-18 00:44:04 +00:00
Argyrios Kyrtzidis 697729a7de Revert r142311, -mios-simulator-version-min does not work correctly.
llvm-svn: 142322
2011-10-18 00:22:49 +00:00
Argyrios Kyrtzidis 7e16493c9b Remove the hack where we sniff the __IPHONE_OS_VERSION_MIN_REQUIRED define.
We can use -mios-simulator-version-min now. rdar://10218700

llvm-svn: 142311
2011-10-17 23:41:26 +00:00
Richard Smith 9fcc5c31c4 Perform lvalue-to-rvalue conversions on __builtin_offsetof array argument index
before typechecking, as suggested by John.

llvm-svn: 142308
2011-10-17 23:29:39 +00:00
Argyrios Kyrtzidis ffe8b1c7be [arcmt] In ARC default for properties is 'strong' so just remove a 'retain' if possible,
instead of changing it to 'strong'. rdar://9984862.

llvm-svn: 142304
2011-10-17 23:14:16 +00:00
Richard Smith b15c11c819 Add -Wc++98-compat warnings for uses of the new keywords 'alignof', 'char16_t',
'char32_t', 'constexpr', 'decltype', 'noexcept', 'nullptr' and 'static_assert'.

llvm-svn: 142302
2011-10-17 23:06:20 +00:00
Nick Lewycky 1d617acef9 Wire up support for the controlling the extended dwarf .file directive. With
r142300 but not this patch, clang -S may emit .s files that assemblers other
than llvm-mc can't parse.

llvm-svn: 142301
2011-10-17 23:05:52 +00:00
Rafael Espindola 70b8d76e64 Implement -static-libstdc++ for linux.
llvm-svn: 142290
2011-10-17 22:14:51 +00:00
Ted Kremenek a08713ce86 Move about 20 random diagnostics under -W flags. Patch by Ahmed Charles!
llvm-svn: 142284
2011-10-17 21:47:53 +00:00
Eli Friedman a4c2602b71 Initial implementation of __atomic_is_lock_free. The input is the size of an atomic type rather than an atomic type itself just to save some implementation pain; I can change that if it seems worthwhile.
I think this is the last hook needed for <atomic> besides defines for ATOMIC_CHAR_LOCK_FREE and friends.

llvm-svn: 142281
2011-10-17 21:44:23 +00:00
Rafael Espindola cc35432550 Implement -static-libgcc on linux and refactor the code responsible for adding
libgcc to the link line into a helper function.

llvm-svn: 142269
2011-10-17 21:39:04 +00:00
DeLesley Hutchins 30abeb1680 Substitute for arguments in method calls -- functionality
llvm-svn: 142267
2011-10-17 21:38:02 +00:00
DeLesley Hutchins a088f67bee Substitute for arguments in method calls -- refactoring
llvm-svn: 142260
2011-10-17 21:33:35 +00:00
Richard Smith b12bf69769 Refactor __attribute__ parsing, and add a diagnostic if the r_paren at the end
of an attrib is missing. gcc does not allow the closing parenthesis to be omitted.

llvm-svn: 142255
2011-10-17 21:20:17 +00:00
Tanya Lattner 49b3841398 The comparison of two vectors should return a signed result. hasIntegerRepresentation() used to always return false for vectors, but since it was changed, it also
changed the return type of a compare of two unsigned vectors to be unsigned. This patch removes the check for hasIntegerRepresentation since its not needed and returns the appropriate signed type.
I added a new test case and updated exisiting test cases that assumed an unsigned result.

llvm-svn: 142250
2011-10-17 21:00:38 +00:00
Fariborz Jahanian 502d2eee09 obj-c++: Fix a IRGen crash when getter is a reference type.
Fix is in Sema. // rdar://10153365

llvm-svn: 142249
2011-10-17 21:00:22 +00:00
Eli Friedman 15b1a7be1e Add missing case to switch.
llvm-svn: 142246
2011-10-17 20:46:28 +00:00
John McCall 444bd25dff Strip qualifiers off the type of an implicit property defined by
only a setter.

llvm-svn: 142236
2011-10-17 20:05:43 +00:00
Argyrios Kyrtzidis bd8b150dfc Introduce ASTConsumer::HandleTopLevelDeclInObjCContainer which accepts
top-level declarations that occurred inside an ObjC container.

This is useful to keep track of such decls otherwise when e.g. a function
is declared inside an objc interface, it is not passed to HandleTopLevelDecl
and it is not inside the DeclContext of the interface that is returned.

llvm-svn: 142232
2011-10-17 19:48:13 +00:00
Argyrios Kyrtzidis 690dccd9d4 Have ObjCMethodDecl::getCanonicalDecl take into account redeclared methods.
llvm-svn: 142231
2011-10-17 19:48:09 +00:00
Argyrios Kyrtzidis 1f4bee5601 Keep track when a ObjC interface/protocol was initially created as a forward reference.
llvm-svn: 142230
2011-10-17 19:48:06 +00:00
Douglas Gregor 7d75bf652b Controlling macros are identifiers, not declarations.
llvm-svn: 142225
2011-10-17 18:53:12 +00:00
John McCall 4124c4924d Teach the ARC compiler to not require __bridge casts when
passing/receiving CF objects at +0 to/from Objective-C methods
or audited C functions.

llvm-svn: 142219
2011-10-17 18:40:02 +00:00
John McCall 8a6b59ad97 Add a new placeholder type to represent "unbridged"
casts in ARC.

No semantic analysis yet.

llvm-svn: 142208
2011-10-17 18:09:15 +00:00
John McCall a072f5d454 Add a helper function for determining whether an expression
has placeholder type.

llvm-svn: 142203
2011-10-17 17:42:19 +00:00
Douglas Gregor 50cefbf212 When we end up having to parse the initializer of a C++ member early
in -fms-extensions mode, make sure we actually use that initializer
after having handled the declaration. Fixes PR11150.

llvm-svn: 142195
2011-10-17 17:09:53 +00:00
Sebastian Redl 962070d49c Revert r142142: "Make a C-style cast a const-cast, to suppress a GCC warning."
Richard already fixed the underlying issue, so the cast was superfluous.

llvm-svn: 142192
2011-10-17 16:53:50 +00:00
Douglas Gregor ebf0049901 For modules, all macros that aren't include guards are implicitly
public. Add a __private_macro__ directive to hide a macro, similar to
the __module_private__ declaration specifier.

llvm-svn: 142188
2011-10-17 15:32:29 +00:00
Douglas Gregor 71129d5e9e When building a module, use the macro definitions on the command line
as part of the hash rather than ignoring them. This means we'll end up
building more module variants (overall), but it allows configuration
macros such as NDEBUG to work so long as they're specified via command
line. More to come in this space.

llvm-svn: 142187
2011-10-17 14:55:37 +00:00
Erik Verbruggen fd979b1eaf Fixed merge-mistake where ActOnAccessSpecifier was called twice for every access specifier. The testcase has been changed to catch this too.
llvm-svn: 142186
2011-10-17 09:54:52 +00:00
Richard Smith eda61288ad Perform an lvalue-to-rvalue conversion on an array index in a __builtin_offsetof expression.
llvm-svn: 142179
2011-10-17 05:48:07 +00:00
Richard Smith 00ab3ae72b Slightly simplify a constant expression check. No functional change.
llvm-svn: 142167
2011-10-16 23:01:09 +00:00
Richard Smith 725810a2bb Split apart the state accumulated during constant expression evaluation and the
end result. Use this split to propagate state information and diagnostics
through more of constant expression evaluation.

llvm-svn: 142159
2011-10-16 21:26:27 +00:00
Peter Collingbourne 5aa6ecb619 Add sema checks for calls to functions taking static array parameters
llvm-svn: 142157
2011-10-16 21:17:32 +00:00
Sebastian Redl b17be8dcfe Implement overload resolution from init lists for scalar parameter types.
llvm-svn: 142148
2011-10-16 18:19:34 +00:00
Sebastian Redl 8b6412af46 Diagnose when omitting braces in direct list-initialization in C++0x.
This also applies to C99-style aggregate literals, should they be used in C++11, since they are effectively identical to constructor call list-initialization syntax.

llvm-svn: 142147
2011-10-16 18:19:28 +00:00
Sebastian Redl 2b47b7a3e6 In the verify-only pass, check that items that don't have an initializer in an init list can be value-initialized, at least when designated initializers are not involved. No test case yet, since early failures cannot be distinguished from late failures until overload resolution works.
llvm-svn: 142146
2011-10-16 18:19:20 +00:00
Sebastian Redl 5999aec4e1 Check for unavailable declarations in Sema::CanUseDecl.
llvm-svn: 142145
2011-10-16 18:19:16 +00:00
Sebastian Redl cc152641c0 Drop the Diagnose parameter from Sema::PerformImplicitConversion again and instead use TryImplicitConversion in CheckSingleAssignmentConstraints when that function is in no-diagnostics mode.
llvm-svn: 142143
2011-10-16 18:19:06 +00:00
Sebastian Redl 47fa9a346d Make a C-style cast a const-cast, to suppress a GCC warning. I should fix the underlying issue eventually, but this interface will probably change anyway.
llvm-svn: 142142
2011-10-16 18:18:59 +00:00
Chandler Carruth 5f9a44f3e9 Fix a silly bug introduced in r142133.
llvm-svn: 142134
2011-10-16 11:05:04 +00:00
Chandler Carruth a7b4414ac2 Clean up some cruft in the library path searching logic by making
'libdir' mean the actual library directory, not the GCC subdirectory of
the library directory. That was just a confusing pattern. Instead,
supply proper GCC subdirectories when scanning for various triple-based
subdirectories with a GCC installation in them. This also makes it much
more obvious how multiarch installations, which have a triple-based
prefix as well as suffix work.

Also clean up our handling of these triple-prefixed trees by using them
in both a multiarch pattern and a non-multiarch pattern whenever they
exist.

Note that this *does not* match what GCC does on Debian, the only truly
multiarch installation I've been able to get installed and test on. GCC
appears to have a bug, and ends up searching paths like
'/lib/../../lib32' which makes no sense what-so-ever. Instead, I've
tried to encode the rational logic that seems clearly intended by GCC's
pattern. GCC ends up with patterns like:

  /lib/../../lib32
  /usr/lib/../../lib32
  /usr/lib/x86_64-linux-gnu/../..lib32

Only the last one makes any sense having a '/../..' in it, so in Clang,
that's the only one which gets a '/../..' in it.

I *think* this will fix Debian multiarch links. I'm committing without
baking this logic into our test suite so I can test on a few different
systems. If all goes well (and no one screams) I'll check in some more
comprehensive tests for multiarch behavior tomorrow.

llvm-svn: 142133
2011-10-16 10:54:30 +00:00
Benjamin Kramer e06b2b7012 Convert inline asm source ranges into clang SourceRanges and print them with the instantiated note.
t.c:2:7: error: invalid operand for instruction
  asm("movl 0(%rax), 0(%edx)");
      ^
<inline asm>:1:16: note: instantiated into assembly here
        movl 0(%rax), 0(%edx)
                      ^~~~~~~
1 error generated.

llvm-svn: 142131
2011-10-16 10:48:28 +00:00
Chandler Carruth 724a1ca207 Hoist the logic I added to compute the macro name into a helper
function. No functionality changed.

llvm-svn: 142128
2011-10-16 09:39:09 +00:00
Chandler Carruth 9e8ce4ccb9 Now that macro expansion notes are real notes and go through the same
formatting as any other diagnostic, they will be properly line wrapped and
otherwise pretty printed. Let's take advantage of that and the new factoring to
add some helpful information to them (much like template backtrace notes and
other notes): the name of the macro whose expansion is being noted. This makes
a world of difference if caret diagnostics are disabled, making the expansion
notes actually useful in this case. It also helps ensure that in edge cases the
information the user needs is present. Consider:

% nl -ba t5.cc
     1  #define M(x, y, z) \
     2    y
     3
     4  M(
     5    1,
     6    2,
     7    3);

We now produce:
% ./bin/clang -fsyntax-only t5.cc
t5.cc:6:3: error: expected unqualified-id
  2,
  ^
t5.cc:2:3: note: expanded from macro: M
  y
  ^
1 error generated.

Without the added information in the note, the name of the macro being expanded
would never be shown.

This also deletes a FIXME to use the diagnostic formatting. It's not yet clear
to me that we *can* do this reasonably, and the production of this message was
my primary goal here anyways.

I'd love any comments or suggestions on improving these notes, their wording,
etc. Currently, I need to make them provide more helpful information in the
presence of a token-pasting buffer, and I'm pondering adding something along
the lines of "expanded from argument N of macro: ...".

llvm-svn: 142127
2011-10-16 09:30:08 +00:00
Chandler Carruth 6679be8155 Fix the original bug in our diagnostic printing that got me started on
this long quest: actually use the note printing machinery for each macro
expansion note rather than a hacky version of it. This will colorize and
format the notes the same as any other. There is still some stuff to fix
here, but it's one step closer.

No test case changes because currently we don't do anything differently
that I can FileCheck for -- I don't really want to try matching the
color escape codes... Suggestions for how to test this are welcome. =]

llvm-svn: 142121
2011-10-16 07:36:11 +00:00
Chandler Carruth dc2f257680 Now that the structure of this is more reasonably laid out, fix a long
standing deficiency: we were providing no macro backtrace information
whenever caret diagnostics were turned off. This sinks the logic for
suppressing the code snippet and caret to the code that actually prints
tho code snippet and caret. Along the way, clean up the naming of
functions, remove some now fixed FIXMEs, and generally improve the
wording and logic of this process.

Add a test case exerecising this functionality. It is notable that the
resulting messages are extremely low quality. I'm working on a follow-up
patch that should address this and have left a FIXME in the test case.

llvm-svn: 142120
2011-10-16 07:20:28 +00:00
Chandler Carruth 5bc0b5ee24 Add proper doxyments to the entry point routine, and remove a dead parameter.
llvm-svn: 142109
2011-10-16 06:24:58 +00:00
Chandler Carruth 3eb8b54e71 Persist the TextDiagnostic object across multiple diagnostics as long as
the SourceManager doesn't change, and the source files don't change.
This greatly simplifies the interfaces and interactions. The lifetime of
the TextDiagnostic object forms the 'session' over which we attempt to
condense and deduplicate information in diagnostics.

llvm-svn: 142104
2011-10-16 02:57:39 +00:00
Chandler Carruth ab4c1daab1 Clean up the names of all the TextDiagnostic methods (and even a static
function) to agree with the coding conventions, and in one case have
a bit more information in it.

llvm-svn: 142088
2011-10-15 23:54:09 +00:00
Chandler Carruth 07c346d220 Move two functions out of the public interface that shouldn't have ever
been there. Also delete their redundant doxyments in favor of those in
the source file. I'm putting the doxyments for private and static
helpers into the implementation file, and only the public interface
doxyments into the header. If folks have strong opinions about this type
of split, feel free to chime in, I'm happy to re-organize.

llvm-svn: 142087
2011-10-15 23:48:02 +00:00
Chandler Carruth a302885b33 Graduate the TextDiagnostic interface to its own header and source file,
making it accessible to anyone from the Frontend library. Still a good
bit of cleanup to do here, but its a good milestone. This ensures that
*all* of the functionality needed to implement the DiagnosticConsumer is
exposed via the generic interface in some form. No sneaky re-use of
static functions.

llvm-svn: 142086
2011-10-15 23:43:53 +00:00
Chandler Carruth 76576db69d Move the message printing to a class-static function so that it can be
part of the TextDiagnostic interface without requiring a full instance.

llvm-svn: 142085
2011-10-15 22:57:29 +00:00
Chandler Carruth 3fc93892ae Move the diagnostic level printing into a class static helper. This will
allow the TextDiagnosticPrinter to continue using it even if
TextDiagnostic is implemented in a separate file.

llvm-svn: 142084
2011-10-15 22:49:21 +00:00
Chandler Carruth 3b73f83d3a Rationalize the last bit of "arbitrary" state that is carried between
diagnostics to control suppression of redundant information. It now
follows the same model as all the other state, and has a bit more clear
semantics.

This is making the duality of the state a bit annoying, and I've added
a FIXME to resolve it. The problem is that I need to lift the
TextDiagnostic up into an externally visible layer before that can
happen.

llvm-svn: 142083
2011-10-15 22:39:16 +00:00
Fariborz Jahanian c27cd1b881 Avoid duplicate unavailbility diagnostics in objc++.
// rdar://10268422

llvm-svn: 142078
2011-10-15 19:18:36 +00:00
Benjamin Kramer a518b22d6b Place static initializers on linux into the ".text.startup" section, so the linker can group them together for performance.
This only has an effect with fairly new binutils (2.21.51 or later). Other ELF targets probably want this as well, but on BSDs binutils is usually old so it doesn't matter.

llvm-svn: 142076
2011-10-15 17:53:33 +00:00
Fariborz Jahanian 7c386f838a obj-c++: allow the getter/setter to return/take parameters
by reference. // rdar://10188258

llvm-svn: 142075
2011-10-15 17:36:49 +00:00
Benjamin Kramer 22d24c287a Replace vectors with arrays.
llvm-svn: 142072
2011-10-15 12:20:02 +00:00
Chandler Carruth 02b88ca980 Neither 'Warning' nor 'NonNote' was a good name for this location...
It's the last include-stack-root we tried to walk up. Use a better name
and better doxyments for it.

llvm-svn: 142071
2011-10-15 12:12:44 +00:00
Chandler Carruth c9b1c180ff Nuke a bunch of FIXMEs that are now fixed. =] Also, remove the now-dead
TextDiagnosticPrinter argument to the TextDiagnostic helper class. This
cements the proper ordering of things: TextDiagnostic is now a viable
stand-alone class for emitting pretty-printed textual diagnostics to
a terminal.

llvm-svn: 142070
2011-10-15 12:07:49 +00:00
Chandler Carruth 636b2501bb Sink the include stack printing into the generic text diagnostic
utility. This is a particularly nice win because it removes a pile of
parameters from these routines. Also name them a bit better. I'm trying
to follow the pattern of 'emit' routines writing directly to what is
expected to be the final output, while 'print' routines take a output
stream argument and can be used to build up intermediate buffers, etc.

Also, fix a bug I spotted by inspection from my last commit where
'LastLoc' and 'LastNonNoteLoc' were reversed. It's really scary that
this didn't trigger a single test failure. Will be working on tests for
more of this functionality now.

llvm-svn: 142069
2011-10-15 12:07:47 +00:00
Chandler Carruth 3d262187f6 Rationalize some of how the locations of prior diagnostics are tracked
across emissions.

1) The include stack printing is conditioned on non-note diagnostics,
   not just on warning diagnostics.
2) Those should be full source locations as they're tied to a source
   manager.
3) We should pass in the prior state to the TextDiagnostic constructor,
   allow it to mutate as diagnostics are emitted, and then cache the
   final state before tearing it down.

Some of this remains incomplete, specifically #3 isn't finished for the
non-note location. That'll come when the include stack printing sinks
down a level.

This also highlights how *completely* bug-ridden this code is. For
example, we currently do all these comparisons of a FullSourceLoc and
a SourceLocation... which silently does a SourceLocation to
SourceLocation comparison, completely disregarding the source manager
from whence one of the arguments came. Oops! Good thing in practice this
wasn't important, but it could in theory be suppressing caret
diagnostics in a second TU on a single clang invocation. I'm hoping to
hammer these bugs out as the refactorings occur, although for so many of
them it's really unlikely I can dream up a test case that would show the
potentially buggy behavior.

llvm-svn: 142067
2011-10-15 11:44:27 +00:00
Chandler Carruth 99eb7dc85f Sink the EmitDiagnosticLoc method down to the generic TextDiagnostic
interface now that its only caller is there.

llvm-svn: 142065
2011-10-15 11:09:23 +00:00
Chandler Carruth c38c7b1b1a Sink the non-caret diagnostic logic down and out of the diagnostic
consumer. The TextDiagnostic interface now has a generic entry point for
emitting a diagnostic which uses a minimal interface that should be
compatible with StoredDiagnostics such as are available in libclang etc.

Some unfortunate shuffling of static functions as things get relocated.
Also some unfortunate public interface points added to
TextDiagnosticPrinter, but those are the next bits to get moved so they
won't last long.

llvm-svn: 142064
2011-10-15 11:09:19 +00:00
Chandler Carruth 342327cac2 Simplify the interface of a helper method in the TextDiagnosticPrinter
to operate directly on the source location and ranges associated with
a diagnostic rather than digging them out of the diagnostic. This had
a side benefit of cleaning up its code a tiny bit by using the ArrayRef
interface.

No functionality changed.

llvm-svn: 142063
2011-10-15 10:48:19 +00:00
Richard Smith e41fac231c Add -Wc++98-compat warning for deduced 'auto' type specifier.
llvm-svn: 142057
2011-10-15 05:42:01 +00:00
Richard Smith 5d164bc5e0 Implement -Wc++98-compat warnings for the parser.
llvm-svn: 142056
2011-10-15 05:09:34 +00:00
Richard Smith da2611199b Refactor: remove redundant check for 'final' specifier when parsing class/struct definition.
llvm-svn: 142054
2011-10-15 04:21:46 +00:00
Richard Smith bffe88027c Rename an ExtWarn to ext_ for consistency.
llvm-svn: 142049
2011-10-15 03:55:17 +00:00
Richard Smith 2db9652b5a Don't warn about use of 'final' in ill-formed C++98 code which didn't use
'final', and don't accept (then silently discard) braced init lists in C++98
new-expressions.

llvm-svn: 142048
2011-10-15 03:38:41 +00:00
Eli Friedman 27ef75b0be Handle an edge case involving the conditional operator and throw expressions. PR10582.
llvm-svn: 142047
2011-10-15 02:10:40 +00:00
Chandler Carruth 09c7464312 Change 'Emit' to 'EmitCaret' which sums up what it *should* be doing.
Also note that it is actually doing much more than it should. This paves
the way for building a more generic 'Emit' routine that is the real
entry point here.

llvm-svn: 142035
2011-10-15 01:21:55 +00:00
Richard Smith acd4d3d52a -Wc++98-compat warnings for the lexer.
This also adds a -Wc++98-compat-pedantic for warning on constructs which would
be diagnosed by -std=c++98 -pedantic (that is, it warns even on C++11 features
which we enable by default, with no warning, in C++98 mode).

llvm-svn: 142034
2011-10-15 01:18:56 +00:00
Douglas Gregor 9e0a5b3900 Teach the ASTImporter to perform DeclContext lookups in a way that
avoids loading data from an external source, since those lookups were
causing some "interesting" recursion in LLDB.

This code is not efficient. I plan to remedy this inefficiency in a
follow-up commit.

llvm-svn: 142023
2011-10-15 00:10:27 +00:00
Peter Collingbourne 60188eb8bf Add c_alignas and cxx_alignas features
llvm-svn: 142020
2011-10-14 23:44:46 +00:00
Anton Korobeynikov f0c267e6e0 Provide half floating point support as a storage only type.
Lack of half FP was a regression compared to llvm-gcc.

llvm-svn: 142016
2011-10-14 23:23:15 +00:00
Eli Friedman 1e7a0c6a1d Attempt to fix Windows buildbot, round 2.
llvm-svn: 142014
2011-10-14 23:10:30 +00:00
Eli Friedman 8d3e43ff4a Add template instantiation support for AtomicExpr.
llvm-svn: 142012
2011-10-14 22:48:56 +00:00
Douglas Gregor 03d1ed304b Teach the ASTImporter not to import redundant fields.
llvm-svn: 142009
2011-10-14 21:54:42 +00:00
Eli Friedman e2c600cf43 Attempt to fix buildbot failure on Windows.
llvm-svn: 142008
2011-10-14 21:52:24 +00:00
Argyrios Kyrtzidis 1ac5da1017 Allow calling ASTUnit::LoadFromCompilerInvocationAction with a previously created ASTUnit.
llvm-svn: 142004
2011-10-14 21:22:05 +00:00
Eli Friedman 4b72fddd99 Misc fixes for atomics. Biggest fix is doing alignment correctly for _Atomic types.
llvm-svn: 142002
2011-10-14 20:59:01 +00:00
Richard Smith f679b5b6a6 -Wc++98-compat: warn on C++11 attributes and alignas.
llvm-svn: 141999
2011-10-14 20:48:27 +00:00
Douglas Gregor 7e1aa5b7ac Don't try to diagnose anything when we're passing incomplete types
through varargs. This only happens when we're in an unevaluated
context, where we don't want to trigger an error anyway. Fixes PR11131
/ <rdar://problem/10288375>.

llvm-svn: 141986
2011-10-14 20:34:19 +00:00
Richard Smith 96bd62f769 Reinstate r141898 (reverted in r141921), without the -Wc++98-compat-variadic-templates flag. Consensus is that -Wc++98-compat is a useful addition to clang, but per-C++11-feature warnings may not be.
Original patch by Jeffrey Yasskin.

llvm-svn: 141985
2011-10-14 20:31:37 +00:00
Richard Smith faa32a9b83 Refactor static analyzer to use simpler interface to constant expression evaluation.
llvm-svn: 141983
2011-10-14 20:22:00 +00:00