Граф коммитов

1908 Коммитов

Автор SHA1 Сообщение Дата
Eli Friedman f66a0dda54 Handle deprecation diagnostics correctly for C struct fields and Objective-C properties/ivars. <rdar://problem/6642337>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161534 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-08 23:04:35 +00:00
Chad Rosier 62f22b8780 [ms-inline asm] Refactor the logic to generate the AsmString into Sema. No
functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161518 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-08 19:48:07 +00:00
Chad Rosier 79efe24e12 [ms-inline asm] Stmt destructors are never called, so allocate the AsmToks using
the ASTContext BumpPtr.  Also use the preferred llvm::ArrayRef interface.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161373 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07 00:29:06 +00:00
Chad Rosier 8f726de554 [ms-inline asm] Pass Tokens to Sema and store them in the AST. No functional
change intended.  No test case as there's no real way to test at this time.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161342 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-06 20:03:45 +00:00
Douglas Gregor d48ab06b17 Tweak code-completion heuristics deciding between a lambda
code-completion and an Objective-C message send, based on Jordan's
feedback.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161049 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-31 15:27:48 +00:00
Douglas Gregor 437fbc51c2 When we encounter a code-completion token while parsing an ill-formed
lambda-introducer in Objective-C++11, fall back to treating the tokens
as an Objective-C message send to provide those (more likely)
completions. Fixes <rdar://problem/11980263>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161015 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-31 00:50:07 +00:00
Richard Smith b9c6261d02 Improvements to vexing-parse warnings. Make the no-parameters case more
accurate by asking the parser whether there was an ambiguity rather than trying
to reverse-engineer it from the DeclSpec. Make the with-parameters case have
better diagnostics by using semantic information to drive the warning,
improving the diagnostics and adding a fixit.

Patch by Nikola Smiljanic. Some minor changes by me to suppress diagnostics for
declarations of the form 'T (*x)(...)', which seem to have a very high false
positive rate, and to reduce indentation in 'warnAboutAmbiguousFunction'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160998 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-30 21:30:52 +00:00
Peter Collingbourne ec98f2fe45 Fix an assertion failure when code completing an auto variable's initialiser.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160857 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-27 12:56:09 +00:00
NAKAMURA Takumi 11abf2ad01 clang/lib: [CMake] Update tblgen'd dependencies.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160851 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-27 06:18:33 +00:00
NAKAMURA Takumi 866abce3b9 clang/lib: [CMake] Reformat, alphabetize lists.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160850 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-27 06:18:12 +00:00
Fariborz Jahanian d30ec7076f objective-c parsing. Don't crash when selector name
is missing in method prototype. // rdar://11939584


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160789 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-26 17:32:28 +00:00
Richard Smith 42926a0655 Pedantic -pedantic correction. Duplicate cv-qualifiers are permitted in C++11
unless they appear in a decl-specifier-seq.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160688 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-24 20:24:58 +00:00
Richard Smith 5969a5f1b7 Do not warn about a function decl / direct init ambiguity if the function has a trailing return type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160646 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23 21:41:30 +00:00
Sylvestre Ledru bed28ac1d1 Fix a typo (the the => the)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160622 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23 08:59:39 +00:00
Richard Smith eab9d6f906 Add diagnostics for comma at end of enum and for extra semicolon at namespace
scope to -Wc++11-extensions. Move extra semicolon after member function
definition diagnostic out of -pedantic, since C++ allows a single semicolon
there. Keep it in -Wextra-semi, though, since it's still questionable.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160618 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-23 05:45:25 +00:00
Francois Pichet b67e7fc607 Allow the parser to recover gracefully if a typename is used to introduce a decltype type.
In Microsoft mode, we emit a warning instead of an error.

This fixes a couple of errors when parsing the MSVC 11 RC headers with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160613 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-22 15:10:57 +00:00
Fariborz Jahanian 090d1bd613 Fixes an ObjC++ parse crash caused by delayed parsing
of c-functions nested in namespace in method implementations
by turning off its delayed parsing until a proper solution is 
figured out. pr13418


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160552 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-20 17:19:54 +00:00
Benjamin Kramer 69b5e952c5 Move helper class into an anonymous namespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160172 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-13 13:25:11 +00:00
Chad Rosier b660446bcf 80-column violations and whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160017 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-10 21:35:27 +00:00
Fariborz Jahanian 6749ae1dbc objective-c: provide fixit hint for @autoreleasepool
and similar other keywords. // rdar://10723084


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159956 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-09 20:00:35 +00:00
Jordan Rose 94f29f4bf5 Better parser recovery in Objective-C containers.
Previously it was possible to get an infinite-loop-on-invalid with a namespace
decl within @interface. Since 'namespace' is normally a safe place to retry
top-level parsing, we just didn't consume the token.

This adds a flag that tracks whether we have temporarily left Objective-C
scope to parse a C-like declaration, and uses that to better recover from
parse problems by stopping at possible method declarations and at @end. To
fix the original problem, we do /not/ stop at 'namespace' when in an
Objective-C @interface or @protocol context (but still do in @implementation).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159941 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-09 16:54:53 +00:00
Fariborz Jahanian 8a10d9fcb5 Added a new memberfor Parser, to be used soon
for doing delayed parsing of c++ method defined in
objc class implementations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159792 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 00:42:20 +00:00
Dmitri Gribenko 8d3ba23f2d Implement AST classes for comments, a real parser for Doxygen comments and a
very simple semantic analysis that just builds the AST; minor changes for lexer
to pick up source locations I didn't think about before.

Comments AST is modelled along the ideas of HTML AST: block and inline content.

* Block content is a paragraph or a command that has a paragraph as an argument
  or verbatim command.
* Inline content is placed within some block.  Inline content includes plain
  text, inline commands and HTML as tag soup.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159790 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-06 00:28:32 +00:00
Fariborz Jahanian 39700f81c5 objective-c++ parsing. Turn off delayed parsing
of out-of-line c++ method definition which happens
to be inside an objc class implementation
until I can figure out how to do it. This is to fix 
a broken project.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159772 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-05 19:34:20 +00:00
Benjamin Kramer 478851c3ed Drop the ASTContext.h include from Stmt.h and fix up transitive users.
This required moving the ctors for IntegerLiteral and FloatingLiteral out of
line which shouldn't change anything as they are usually called through Create
methods that are already out of line.

ASTContext::Deallocate has been a nop for a long time, drop it from ASTVector
and make it independent from ASTContext.h

Pass the StorageAllocator directly to AccessedEntity so it doesn't need to
have a definition of ASTContext around.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159718 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-04 17:04:04 +00:00
Fariborz Jahanian b0ed95c273 Obj-C++11 parser: handle a fall out of delayed
c-function parsing when a declaration with
C++0x braced-init-list is inside an @implementation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159693 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-03 23:22:13 +00:00
Fariborz Jahanian 3b5f9dc024 Obj-C++11 parser: fix broken parsing of c-function
defined in class implementations.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159691 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-03 22:54:28 +00:00
Fariborz Jahanian cda1041710 Obj-C++11 parser: turn off buffering of
c-function defined in objc class
implementation for now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159690 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-03 22:29:23 +00:00
Fariborz Jahanian a1eec4bd19 objective-c: Refactor parse/sema portion of
objective-c's fast enumeration statement,
for more work to come.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159689 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-03 22:00:52 +00:00
Fariborz Jahanian 6c89eafc90 objective-c: just as we have done for method definitions,
c-functions declared in implementation should have their 
parsing delayed until the end so, they can access forward
declared private methods. // rdar://10387088


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159626 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-02 23:37:09 +00:00
Richard Smith 139be7007e A ':' after an enum-specifier at class scope is a bitfield, not a typo for a ';'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159549 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-02 19:14:01 +00:00
Jordan Rose f70a88612a Add support for the C11 _Alignof keyword.
This behaves like the existing GNU __alignof and C++11 alignof keywords;
most of the patch is simply adding the third token spelling to various places.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159494 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-30 21:33:57 +00:00
David Blaikie e75d9cfbf4 Use -frewrite-includes for crash reports.
In future changes we should:
* use __builtin_trap rather than derefing 'random' volatile pointers.
* avoid dumping temporary files into /tmp when running tests, instead
  preferring a location that is properly cleaned up by lit.

Review by Chandler Carruth.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159469 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-29 22:03:56 +00:00
Douglas Gregor 0963017dcb Support the use of "=delete" and "=default" with delayed template
parsing. Fixes <rdar://problem/11700604>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159380 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-28 21:43:01 +00:00
Chad Rosier 8decdee5fd Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159235 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-26 22:30:43 +00:00
Richard Smith c9f3517007 Extend the "expected ';' after struct" logic to also apply to enums, and to
struct and enum forward-declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159164 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-25 21:37:02 +00:00
John McCall 1e12b3d777 Recognize GNU attributes after 'enum class'. Fixes the libc++ build.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159089 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-23 22:30:04 +00:00
Sean Hunt 2edf0a2520 Clean up a large number of C++11 attribute parse issues, including parsing
attributes in more places where we didn't and catching a lot more issues.

This implements nearly every aspect of C++11 attribute parsing, except for:
 - Attributes are permitted on explicit instantiations inside the declarator
   (but not preceding the decl-spec)
 - Attributes are permitted on friend declarations of functions.
 - Multiple instances of the same attribute in an attribute-list (e.g.
   [[noreturn, noreturn]], not [[noreturn]] [[noreturn]] which is conforming)
   are allowed.
The first two are marked as expected-FIXME in the test file and the latter
is probably a defect and is currently untested.

Thanks to Richard Smith for providing the lion's share of the testcases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159072 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-23 05:07:58 +00:00
Nico Weber 28ad063b27 Support L__FUNCTION__ in microsoft mode, PR11789
Heavily based on a patch from
Aaron Wishnick <aaron.s.wishnick@gmail.com>.

I'll clean up the duplicated function in CodeGen as
a follow-up, later today or tomorrow.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159060 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-23 02:07:59 +00:00
Kaelyn Uhrain c1fb542656 Perform typo correction for base class specifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159046 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-22 23:37:05 +00:00
Fariborz Jahanian 56242baaae objective-c: deprecated C-like parameters in Objective-C
method declarations.
// rdar://11578353.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158929 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 18:43:08 +00:00
Chandler Carruth b0d8671f95 Remove a goofy CMake hack and use the standard CMake facilities to
express library-level dependencies within Clang.

This is no more verbose really, and plays nicer with the rest of the
CMake facilities. It should also have no change in functionality.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158888 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 01:30:21 +00:00
Dmitri Gribenko 056e2c3005 Unbreak GCC build: GCC doesn't like clang::Parser::CommentHandler and class clang::CommentHandler to have same name.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158780 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-20 01:06:08 +00:00
Dmitri Gribenko aa0cd85838 Structured comment parsing, first step.
* Retain comments in the AST
* Serialize/deserialize comments
* Find comments attached to a certain Decl
* Expose raw comment text and SourceRange via libclang


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158771 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-20 00:34:58 +00:00
Sean Hunt 8e083e71d4 Reapply r158700 and fixup patches, minus one hunk that slipped through and
caused a crash in an obscure case. On the plus side, it caused me to catch
another bug by inspection.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158767 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 23:57:03 +00:00
Aaron Ballman fc685ace38 Reapplying the changes from r158717 as they were rolled back to avoid merge conflicts from a separate problematic patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158750 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 22:09:27 +00:00
Jakob Stoklund Olesen 3532936f4f Revert r158700 and dependent patches r158716, r158717, and r158731.
The original r158700 caused crashes in the gcc test suite,
g++.abi/vtable3a.C among others. It also caused failures in the libc++
test suite.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158749 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 21:48:43 +00:00
James Dennett 38b0603314 Documentation cleanup: fixing file headers to use Doxygen \file markup while
also being sufficiently conformant to LLVM's coding standards.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158739 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 21:02:26 +00:00
Meador Inge 9416d42468 Revert predefined decl tracking.
r158085 added some logic to track predefined declarations.  The main reason we
had predefined declarations in the input was because the __builtin_va_list
declarations were injected into the preprocessor input.  As of r158592 we 
explicitly build the __builtin_va_list declarations.  Therefore the predefined
decl tracking is no longer needed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158732 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 18:17:30 +00:00
Aaron Ballman ed35fd1c6d Improves parsing and semantic analysis for MS __declspec attributes. This includes support for the align (which fixes PR12631).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158717 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 13:49:26 +00:00
Sean Hunt bfcb037a34 Improve the specification of spellings in Attr.td.
Note that this is mostly a structural patch that handles the change from the old
spelling style to the new one. One consequence of this is that all AT_foo_bar
enum values have changed to not be based off of the first spelling, but rather
off of the class name, so they are now AT_FooBar and the like (a straw poll on
IRC showed support for this). Apologies for code churn.

Most attributes have GNU spellings as a temporary solution until everything else
is sorted out (such as a Keyword spelling, which I intend to add if someone else
doesn't beat me to it). This is definitely a WIP.

I've also killed BaseCheckAttr since it was unused, and I had to go through
every attribute anyway.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158700 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19 03:39:03 +00:00
Sean Hunt 93f95f2a2c Handle C++11 attribute namespaces automatically.
Now, as long as the 'Namespaces' variable is correct inside Attr.td, the
generated code will correctly admit a C++11 attribute only when it has the
appropriate namespace(s).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158661 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18 16:13:52 +00:00
Michael J. Spencer adc6cbf5b5 [MSExtensions] Add support for __forceinline.
__forceinline is a combination of the inline keyword and __attribute__((always_inline))

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158653 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18 07:00:48 +00:00
Richard Smith 19a2702042 Extend the error recovery for a template-argument-list terminated by '>>' to
also deal with '>>>' (in CUDA), '>=', and '>>='. Fix the FixItHints logic to
deal with cases where the token is followed by an adjacent '=', '==', '>=',
'>>=', or '>>>' token, where a naive fix-it would result in a differing token
stream on a re-lex.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158652 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18 06:11:04 +00:00
James Dennett e30d3ff7c5 Documentation cleanup:
* Added \file, \brief and \verbatim...\endverbatim markup, particularly around
  documentation of subset of the grammars that are being parsed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158628 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-17 04:36:28 +00:00
Kaelyn Uhrain 50dc12ad05 Recover when correcting an unknown type name to a keyword like "struct".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158573 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15 23:45:58 +00:00
Kaelyn Uhrain 7bf33401ac Move isCXXSimpleTypeSpecifier from Parser to Sema and tweak it for wider use.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158572 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15 23:45:51 +00:00
Douglas Gregor 03f1eb031b Check the parameter lists and return type of both blocks and lambdas
for unexpanded parameter packs. Fixes the crash-on-invalid in
PR13117.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158525 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15 16:59:29 +00:00
James Dennett 7a90c8ba86 Documentation cleanup: escape Objective-C @ symbols in Doxygen comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158495 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15 06:52:33 +00:00
Chad Rosier b3b26bfe61 [ms-inline-asm] The __asm keyword is a statement separator, so multiple asm
statements are allowed on the same line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158372 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-12 20:30:26 +00:00
Chad Rosier a01eddbd07 [ms-inline-asm] Cleanup MS style inline assembly parsing.
Specifically, improve the handling of whitespace, stop saving tokens that are
in comments and fix the case where we have a comment followed by a closing brace
on the next line.

Unfortunately, there's no easy way of testing this code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158367 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-12 19:03:42 +00:00
Richard Smith 54655be655 If parsing a trailing-return-type fails, don't pretend we didn't have one at
all. Suppresses follow-on errors mentioned in PR13074.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158348 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-12 01:51:59 +00:00
Chad Rosier 8cd64b4c55 Etch out the code path for MS-style inline assembly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158325 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-11 20:47:18 +00:00
James Dennett 17d26a6c1f Documentation cleanup, fixing Doxygen markup. Mostly this avoids common terms
such as "protocol" and "expression" being implicitly turned into links to
mistakenly-generated Doxygen pages:
- Escaping @ symbols when Doxygen would otherwise incorrectly interpret them;
- Escaping # symbols when they're not intended as explicit Doxygen link 
  requests, such as when discussing preprocessor directives;
- In one odd case, unescaping @ in @__experimental_modules_import, because
  Doxygen wrote '\@' to the output in that case, causing the example in the
  description of ImportDecl to be wrong; and
- Fixing a typo: @breif -> @brief.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158299 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-11 06:19:40 +00:00
Richard Smith ca5233044e PR13064: Store whether an in-class initializer uses direct or copy
initialization, and use that information to produce the right kind of
initialization during template instantiation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158288 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-10 03:12:00 +00:00
Douglas Gregor c86c40b912 Whenever we have a BalancedDelimiterTracker, we have a 'nested' scope
where '>' is going to behave as an operator (and not as a '>' closing
a template argument list).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158111 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06 21:18:07 +00:00
Benjamin Kramer facde171ae Remove unused private member variables found by clang's new -Wunused-private-field.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158086 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06 17:32:50 +00:00
Jordan Rose d73ef135ba Add pedantic warning -Wempty-translation-unit (C11 6.9p1).
In standard C since C89, a 'translation-unit' is syntactically defined to have
at least one "external-declaration", which is either a decl or a function
definition. In Clang the latter gives us a declaration as well.

The tricky bit about this warning is that our predefines can contain external
declarations (__builtin_va_list and the 128-bit integer types). Therefore our
AST parser now makes sure we have at least one declaration that doesn't come
from the predefines buffer.

Also, remove bogus warning about empty source files. This doesn't catch source
files that only contain comments, and never fired anyway because of our
predefines.

PR12665 and <rdar://problem/9165548>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158085 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06 17:25:21 +00:00
Fariborz Jahanian 6d1de1b866 objc: position of 'fixit' was off by one.
This patch fixes it. // rdar://11488351


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157646 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-29 21:52:45 +00:00
John McCall c052dbb2d8 Recognize the MS inheritance attributes and turn them into attributes
on the RecordDecl.  Persist the MS portability type attributes and
ignore them in Sema rather than the parser.

Patch by João Matos!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157288 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-22 21:28:12 +00:00
Fariborz Jahanian 18df0eba83 objective-c: provide a useful 'fixit' suggestion when
errornously using commas to separate ObjC message arguments.
// rdar://11376372


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157216 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-21 22:43:44 +00:00
Benjamin Kramer 268efba18e CXXThisScopeRAII objects aren't free, don't compute one if it's unused.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156987 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-17 12:01:52 +00:00
Argyrios Kyrtzidis 5641b0d025 [libclang/AST] When declaring a local class, don't neglect to set the end location
of the DeclStmt node, otherwise libclang will not work for anything inside that
class.

rdar://10837710

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156966 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 23:49:15 +00:00
Richard Smith 25582fc0ae Recover better from a missing 'typename' in a function template definition.
Disambiguate past such a potential problem, and use the absence of 'typename'
to break ties in favor of a parenthesized thingy being an initializer, if
nothing else in the declaration disambiguates it as declaring a function.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156963 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 23:40:17 +00:00
Richard Trieu 4b0e6f1da3 Move the warnings for extra semi-colons under -Wextra-semi. Also, added
a warning for an extra semi-colon after function definitions.  Added logic
so that a block of semi-colons on a line will only get one warning instead
of a warning for each semi-colon.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156934 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 19:04:59 +00:00
David Blaikie def07624ec Include the correct conversion context locations for condition expressions.
This improves the conversion diagnostics (by correctly pointing to the loop
construct for conversions that may've been caused by the contextual conversion
to bool caused by a condition expression) and also causes the NULL conversion
warnings to be correctly suppressed when crossing a macro boundary in such a
context. (previously, since the conversion context location was incorrect, the
suppression could not be performed)

Reported by Nico Weber as feedback to r156826.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156901 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 04:20:04 +00:00
Argyrios Kyrtzidis 7d24e289be [libclang/AST] Index references of protocols in "@protocol(...)" syntax.
To do that, keep track of the location of the protocol id in the ObjCProtocolExpr
AST node.

rdar://11190837

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156890 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 00:50:02 +00:00
Richard Smith 7514db2703 Typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156860 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 21:42:17 +00:00
Richard Smith 8f0a7e7845 If we see a declaration which is either missing a type or has a malformed type,
and the thing we have has a scope specifier, and we're in a context that doesn't
allow declaring a qualified name, then the error is a malformed type, not a
missing type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156856 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 21:29:55 +00:00
Richard Smith 827adaff66 Don't use the implicit int rule for error recovery in C++. Instead, try to
disambiguate whether the type name was forgotten or mistyped.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156854 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 21:01:51 +00:00
Richard Smith 23756776ea Recover properly from a redundant 'typename' before a non-nested name. This is
permitted as a Microsoft extension. Patch by William Wilson! (Plus some minor
tweaking by me.)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156786 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-14 22:43:34 +00:00
Argyrios Kyrtzidis edd27602f9 Don't crash when using objc boxed expression with parsing error.
rdar://11426994

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156565 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-10 20:02:36 +00:00
Fariborz Jahanian 1de6a6cb48 objective-c. Fixes a 'fixit' where location of
'*' on objective-c class name was misplaced.
// rdar://11311333


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156517 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-09 21:49:29 +00:00
Richard Smith a971d2410f Push the knowledge that we are parsing a type-id/type-name further into the
parser, and use it to emit better diagnostics in cases where an identifer
can't be looked up as a type name.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156508 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-09 20:55:26 +00:00
Richard Smith f63eee78a3 Stop AltiVec parsing from going down the 'implicit int' codepath as part of its
normal parse for token sequences like 'vector pixel foo'. This incidentally also
fixes a couple of wrong-parse issues.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156503 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-09 18:56:43 +00:00
Richard Smith 83a22ecbf5 Recover properly if a class member declaration starts with a scope specifier
or template-id which can't be parsed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156468 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-09 08:23:23 +00:00
John McCall 13489673b8 Change how we suppress access control in explicit instantiations
so that we actually accumulate all the delayed diagnostics.  Do
this so that we can restore those diagnostics to good standing
if it turns out that we were wrong to suppress, e.g. if the
tag specifier is actually an elaborated type specifier and not
a declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156291 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 06:16:58 +00:00
John McCall 9257664568 Refactor DelayedDiagnostics so that it keeps diagnostics in
separate pools owned by the RAII objects that keep pushing
decl state.  This gives us quite a bit more flexibility.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156289 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 06:16:41 +00:00
Richard Smith e0d3b4cd2b Add -Wimplicit-fallthrough warning flag, which warns on fallthrough between
cases in switch statements. Also add a [[clang::fallthrough]] attribute, which
can be used to suppress the warning in the case of intentional fallthrough.

Patch by Alexander Kornienko!

The handling of C++11 attribute namespaces in this patch is temporary, and will
be replaced with a cleaner mechanism in a subsequent patch.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156086 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-03 18:27:39 +00:00
Richard Smith a058fd4f0a Revert most of r154844, which was disabled in r155975. Keep around the
refactorings in that revision, and some of the subsequent bugfixes, which
seem to be relevant even without delayed exception specification parsing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156031 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-02 22:22:32 +00:00
Douglas Gregor fb5825dca4 Replace a ConsumeAnyToken() call with ConsumeToken() when we know
we're looking at a normal token. Tiny positive impact -fsyntax-only
time for <rdar://problem/11004361>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155988 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-02 14:34:16 +00:00
Richard Smith 6deb820a1d Disable our non-standard delayed parsing of exception specifications. Delaying
the parsing of such things appears to be a conforming extension, but it breaks
libstdc++4.7's std::pair.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155975 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-02 01:29:43 +00:00
Kaelyn Uhrain 1a200a87c1 A couple of very small tweaks suggested by Doug in reply to r155580 and r155163.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155870 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-01 01:16:25 +00:00
Richard Smith e531001b7e PR12688: ParseCXXClassMemberDeclaration's sometimes-null ThisDecl takes another
victim. Don't crash if we have a delay-parsed exception specification for a
class member which is invalid in a way which precludes building a FunctionDecl.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155788 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-29 07:31:09 +00:00
Chris Lattner bddc7e5ed3 improve error recovery for extra ')'s after a if/switch/while condition. Before:
t.c:3:9: error: expected expression
  if (x)) {
        ^

.. which isn't even true - a statement or expression is fine.  After:

t.c:3:9: error: extraneous ')' after condition, expected a statement
  if (x)) {
        ^

This is the second part of PR12595



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155762 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-28 16:24:20 +00:00
Chris Lattner 8bb21d32e9 switch some uses of ExpectAndConsume(tok::semi to use ExpectAndConsumeSemi. This allows
us to improve this diagnostic (telling us to insert another ")":

t.c:2:19: error: expected ';' at end of declaration
  int x = 4+(5-12));
                  ^
                  ;
to:
t.c:2:19: error: extraneous ')' before ';'
  int x = 4+(5-12));
                  ^

...telling us to remove the ")".  This is PR12595.  There are more uses of ExpectAndConsumeSemi
that could be switched over, but I don't hit them on a daily basis :)





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155759 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-28 16:12:17 +00:00
Kaelyn Uhrain 392b3f5798 Imrpove the note text for when a non-type decl hides a tag type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155723 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-27 18:26:49 +00:00
Kaelyn Uhrain aec2ac67e7 Add note to help explain why a tag such as 'struct' is needed to refer
to a given type, when the reason is that there is a non-type decl with
the same name.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155677 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-26 23:36:17 +00:00
Eli Friedman 9b94cd1b25 Add a missing ExpressionEvaluationContext for template default arguments. Fixes PR12581.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155670 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-26 22:43:24 +00:00
Chad Rosier 26d6023cb0 Typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155596 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-25 22:51:41 +00:00
Richard Smith 2b2a0876c9 Don't try to delay parsing the exception specification for a data member of a
class; we would never actually parse it and attach it to the type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155426 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-24 05:48:42 +00:00
Benjamin Kramer 0eb7526cd2 Remove unnecessary StringRef->char*->StringRef conversion, which read uninitialized memory if the input wasn't 0-terminated.
Found by valgrind.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155323 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-22 20:43:30 +00:00
Richard Smith a4156b8574 Fix regression in r154844. If necessary, defer computing adjusted destructor
exception specifications in C++11 until after we've parsed the exception
specifications for nested classes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155293 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-21 18:42:51 +00:00
Kaelyn Uhrain 434ed260eb In Parser::isCXXDeclarationSpecifier, consider a non-type identifier
followed by an identifier as declaration specificer (except for ObjC).
This allows e.g. an out-of-line C++ member function definitions to be
recognized as functions and not as variable declarations if the type
name for the first parameter is not recognized as a type--say, when there
is a function name shadowing an enum type name and the parameter is
missing the "enum" keyword needed to distinguish the two.

Note that returning TPResult::Error() instead of TPResult::True()
appears to have the same end result, while TPResult::Ambiguous()
results in a crash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155163 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 23:17:45 +00:00
Patrick Beard eb382ec150 Implements boxed expressions for Objective-C. <rdar://problem/10194391>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155082 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 00:25:12 +00:00
Douglas Gregor 74e2fc332e Implement the last part of C++ [class.mem]p2, delaying the parsing of
exception specifications on member functions until after the closing
'}' for the containing class. This allows, for example, a member
function to throw an instance of its own class. Fixes PR12564 and a
fairly embarassing oversight in our C++98/03 support.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154844 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-16 18:27:27 +00:00
Douglas Gregor cefc3afac1 Implement C++11 [expr.prim.general]p3, which permits the use of 'this'
in the declaration of a non-static member function after the
(optional) cv-qualifier-seq, which in practice means in the exception
specification and late-specified return type. 

The new scheme here used to manage 'this' outside of a member function
scope is more general than the Scope-based mechanism previously used
for non-static data member initializers and late-parsesd attributes,
because it can also handle the cv-qualifiers on the member
function. Note, however, that a separate pass is required for static
member functions to determine whether 'this' was used, because we
might not know that we have a static function until after declaration
matching.

Finally, this introduces name mangling for 'this' and for the implicit
'this', which is intended to match GCC's mangling. Independent
verification for the new mangling test case would be appreciated.

Fixes PR10036 and PR12450.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154799 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-16 07:05:22 +00:00
Benjamin Kramer d306cf7b21 Delete late parsed attributes instead of leaking them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154746 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-14 12:44:47 +00:00
Benjamin Kramer 13bb701f2f Parser: Don't manage TemplateAnnotationIds in a delayed cleanup pool.
Instead, make it the allocation function's responsibility to add them
to a list and clear it when a top-level decl is finished.

This plugs leakage of TemplateAnnotationIds. DelayedCleanupPool is
ugly and unused, remove it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154743 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-14 12:14:03 +00:00
Richard Smith 534986f2b2 Add an AttributedStmt type to represent a statement with C++11 attributes
attached. Since we do not support any attributes which appertain to a statement
(yet), testing of this is necessarily quite minimal.

Patch by Alexander Kornienko!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154723 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-14 00:33:13 +00:00
Erik Verbruggen 6a91d38561 Added a flag to the parser to skip method bodies.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154584 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-12 10:11:59 +00:00
Richard Smith 994d73f847 Part of PR10101: after a parse error in a declaration, try harder to find the
right place to pick up parsing. In C++, this had a tendency to skip everything
declared within headers if the TU starts with garbage.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154530 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-11 20:59:20 +00:00
Richard Smith 6ce48a70ac Support C++11 attributes at the start of a parameter-declaration.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154476 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-11 04:01:28 +00:00
Chandler Carruth 2c6dbd7f55 Fix GCC's pedantic return-type warning -- this enum is fully covered.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154399 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-10 16:03:08 +00:00
Richard Smith c56298d87a Parsing of C++11 attributes:
* Alternative tokens (such as 'compl') are treated as identifiers in
   attribute names.
 * An attribute-list can start with a comma.
 * An ellipsis may not be used with either of our currently-supported
   C++11 attributes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154381 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-10 03:25:07 +00:00
Richard Smith 6ee326af4e Disambiguation of '[[':
* In C++11, '[[' is ill-formed unless it starts an attribute-specifier. Reject
   array sizes and array indexes which begin with a lambda-expression. Recover by
   parsing the lambda as a lambda.
 * In Objective-C++11, either '[' could be the start of a message-send.
   Fully disambiguate this case: it turns out that the grammars of message-sends,
   lambdas and attributes do not actually overlap. Accept any occurrence of '[['
   where either '[' starts a message send, but reject a lambda in an array index
   just like in C++11 mode.

Implement a couple of changes to the attribute wording which occurred after our
attributes implementation landed:
 * In a function-declaration, the attributes go after the exception specification,
   not after the right paren.
 * A reference type can have attributes applied.
 * An 'identifier' in an attribute can also be a keyword. Support for alternative
   tokens (iso646 keywords) in attributes to follow.

And some bug fixes:
 * Parse attributes after declarator-ids, even if they are not simple identifiers.
 * Do not accept attributes after a parenthesized declarator.
 * Accept attributes after an array size in a new-type-id.
 * Partially disamiguate 'delete' followed by a lambda. More work is required
   here for the case where the lambda-introducer is '[]'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154369 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-10 01:32:12 +00:00
David Blaikie eb52f86a62 Fix bugs found by -Wconstant-conversion improvements currently under review.
Specifically, using a an integer outside [0, 1] as a boolean constant seems to
be an easy mistake to make with things like "x == a || b" where the author
intended "x == a || x == b".

The bug caused by calling SkipUntil with three token kinds was also identified
by a VC diagnostic & reported by Francois Pichet as review feedback for my
commit r154163. I've included test cases to verify the error recovery that was
broken/poorly implemented due to this bug.

The other fix (lib/Sema/SemaExpr.cpp) seems like that code was never actually
reached in any of Clang's tests & is related to Objective C features I'm not
familiar with, so I've not been able to construct a test case for it. Perhaps
someone else can.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154325 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-09 16:37:11 +00:00
David Blaikie b031eab1c0 Remove "parse error" in favor of more descriptive diagnostics.
In a few cases clang emitted a rather content-free diagnostic: 'parse error'.
This change replaces two actual cases (template parameter parsing and K&R
parameter declaration parsing) with more specific diagnostics and removes a
third dead case of this in the BalancedDelimiterTracker (the ctor already
checked the invariant necessary to ensure that the diag::parse_error was never
actually used).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154224 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-06 23:33:59 +00:00
Patrick Beard b2f6820773 Added a new attribute, objc_root_class, which informs the compiler when a root class is intentionally declared.
The warning this inhibits, -Wobjc-root-class, is opt-in for now. However, all clang unit tests that would trigger
the warning have been updated to use -Wno-objc-root-class. <rdar://problem/7446698>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154187 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-06 18:12:22 +00:00
DeLesley Hutchins cf2fa2f0c9 Fixed scoping error for late parsed attributes in nested classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154173 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-06 15:10:17 +00:00
David Blaikie 9df1b963a6 Restrict fixit for missing 'class' in template template parameters.
Based on Doug's feedback to r153887 this omits the FixIt if the following token
isn't syntactically valid for the context. (not a comma, '...', identifier,
'>', or '>>')

There's a bunch of work to handle the '>>' case, but it makes for a much more
pleasant diagnostic in this case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154163 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-06 05:26:43 +00:00
David Blaikie a82354563e Improve & simplify diagnostic for missing 'class' in template template parameter.
Change suggested by Sebastian Redl on review feedback from r153887.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154102 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-05 16:56:02 +00:00
Richard Smith 5a5a971908 For PR11916: Add support for g++'s __int128 keyword. Unlike __int128_t, this is
a type specifier and can be combined with unsigned. This allows libstdc++4.7 to
be used with clang in c++98 mode.

Several other changes are still required for libstdc++4.7 to work with clang in
c++11 mode.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153999 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-04 06:24:32 +00:00
John McCall 73f428cf2c Enter an expression evaluation context when parsing
statement-expressions.  Prevents cleanups and such from being
claimed by the first full-expression in the block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153989 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-04 01:27:53 +00:00
David Blaikie 219c2e20ff Remove windows line endings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153895 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-02 20:59:49 +00:00
David Blaikie 460ef136eb Correct error recovery when missing 'class' in a template template parameter.
The diagnostic message correctly informs the user that they have omitted the
'class' keyword, but neither suggests this insertion as a fixit, nor attempts
to recover as if they had provided the keyword.

This fixes the recovery, adds the fixit, and adds a separate diagnostic and
corresponding replacement fixit for cases where the user wrote 'struct' or
'typename' instead of 'class' (suggested by Richard Smith as a possible common
mistake).

I'm not sure the diagnostic message for either the original or new cases feel
very Clang-esque, so I'm open to suggestions there. The fixit hints make it
fairly easy to see what's required, though.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153887 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-02 19:15:28 +00:00
Richard Smith 9988f28fe7 Reject 'template<typename...Ts> void f(Ts ...(x));'. Add a special-case
diagnostic and a fix-it to explain to the user where the ellipsis is
supposed to go.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153622 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-29 01:16:42 +00:00
Richard Smith 2259286fc5 If we see '(...' where we're expecting an abstract-declarator, that doesn't
necessarily mean we've found a function declarator. If the next token is not
a ')', this is actually a parenthesized pack expansion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153544 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-27 23:05:05 +00:00
Richard Smith 5d8388ce6e Add cross-referencing comments to ParseDirectDeclarator to note that
isConstructorDeclaration also needs updating for any extension to the
grammar of a direct-declarator.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153490 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-27 01:42:32 +00:00
Richard Smith 412e0cc52e When we see 'Class(X' or 'Class::Class(X' and we suspect that it names a
constructor, but X is not a known typename, check whether the tokens could
possibly match the syntax of a declarator before concluding that it isn't
a constructor. If it's definitely ill-formed, assume it is a constructor.

Empirical evidence suggests that this pattern is much more often a
constructor with a typoed (or not-yet-declared) type name than any of the
other possibilities, so the extra cost of the check is not expected to be
problematic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153488 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-27 00:56:56 +00:00
Argyrios Kyrtzidis 5d5ed59f1e [parser] If there are unmatched braces in a function definition, try to
recover by returning the statements that we parsed so far, instead of
dropping the whole function body.

rdar://10967343

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153367 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-24 02:26:51 +00:00
Richard Smith 1af83c444e Support for definitions of member enumerations of class templates outside the
class template's definition, and for explicit specializations of such enum
members.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153304 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-23 03:33:32 +00:00
Sebastian Redl ca8937111c Fix the other place where C++98 work for initializer lists was necessary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153129 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-20 21:24:03 +00:00
Sebastian Redl 3e280b58db Add the missing compatibility warning for braced initializers as default arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153026 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-18 22:25:45 +00:00
Axel Naumann e55329d683 From Vassil Vassilev:
Enable incremental parsing by the Preprocessor,
where more code can be provided after an EOF.
It mainly prevents the tearing down of the topmost lexer.
To be used like this:
PP.enableIncrementalProcessing();
while (getMoreSource()) {
  while (Parser.ParseTopLevelDecl(ADecl)) {...}
}
PP.enableIncrementalProcessing(false);


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152914 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-16 10:40:17 +00:00
Richard Smith 6d96d3ad1d Small cleanup: move trailing-return-type special-casing into
getDeclSpecContextFromDeclaratorContext.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152766 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-15 01:02:11 +00:00
Sebastian Redl 84407ba82a Parse brace initializers as default arguments. PR12236.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152721 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-14 15:54:00 +00:00
David Blaikie 6f42669b7c Fix a crash-on-invalid found by -Wlogical-op-parentheses.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152559 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-12 15:39:49 +00:00
Richard Smith 7796eb5643 Fix parsing of trailing-return-type. Types are syntactically prohibited from
being defined here: [] () -> struct S {} does not define struct S.

In passing, implement DR1318 (syntactic disambiguation of 'final').


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152551 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-12 08:56:40 +00:00
Richard Smith 69730c115c Fix parsing of type-specifier-seq's. Types are syntactically allowed to be
defined here, but not semantically, so

  new struct S {};

is always ill-formed, even if there is a struct S in scope.

We also had a couple of bugs in ParseOptionalTypeSpecifier caused by it being
under-loved (due to it only being used in a few places) so merge it into
ParseDeclarationSpecifiers with a new DeclSpecContext. To avoid regressing, this
required improving ParseDeclarationSpecifiers' diagnostics in some cases. This
also required teaching ParseSpecifierQualifierList about constexpr... which
incidentally fixes an issue where we'd allow the constexpr specifier in other
bad places.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152549 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-12 07:56:15 +00:00
David Blaikie 4e4d08403c Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-11 07:00:24 +00:00
Douglas Gregor 93a7067302 Document the availability attribute
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152531 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-11 04:53:21 +00:00
Richard Smith 36f5cfe4df Support for raw and template forms of numeric user-defined literals,
and lots of tidying up.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152392 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-09 08:00:36 +00:00
Richard Smith 3376277570 Fix a couple of issues with literal-operator-id parsing, and provide recovery
for a few kinds of error. Specifically:

Since we're after translation phase 6, the "" token might be formed by multiple
source-level string literals. Checking the token width is not a correct way of
detecting empty string literals, due to escaped newlines. Diagnose and recover
from a missing space between "" and suffix, and from string literals other than
"", which are followed by a suffix.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152348 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-08 23:06:02 +00:00
Douglas Gregor d78ef5b941 Streamline BalancedDelimiterTracker, by eliminating the duplicate
paren/brace/bracket tracking (the Consume* functions already did it),
removing the use of ConsumeAnyToken(), and moving the hot paths inline
with the error paths out-of-line.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152274 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-08 01:00:17 +00:00
Benjamin Kramer 8b8d9534f1 Silence unused variable warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152170 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07 00:14:40 +00:00
Michael Han e53ac8aea2 Refactor Clang sema attribute handling.
This submission improves Clang sema handling by using Clang tablegen
to generate common boilerplate code. As a start, it implements AttributeList
enumerator generation and case statements for AttributeList::getKind.

A new field "SemaHandler" is introduced in Attr.td and by default set to 1
as most of attributes in Attr.td have semantic checking in Sema. For a small
number of attributes that don't appear in Sema, the value is set to 0.

Also there are a small number of attributes that only appear in Sema but not
in Attr.td. Currently these attributes are still hardcoded in Sema AttributeList.

Reviewed by Delesley Hutchins.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152169 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-07 00:12:16 +00:00
Ted Kremenek ebcb57a8d2 Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,
NSNumber, and boolean literals.  This includes both Sema and Codegen support.
Included is also support for new Objective-C container subscripting.

My apologies for the large patch.  It was very difficult to break apart.
The patch introduces changes to the driver as well to cause clang to link
in additional runtime support when needed to support the new language features.

Docs are forthcoming to document the implementation and behavior of these features.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152137 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-06 20:05:56 +00:00
Richard Smith 99831e4677 User-defined literals: reject string and character UDLs in all places where the
grammar requires a string-literal and not a user-defined-string-literal. The
two constructs are still represented by the same TokenKind, in order to prevent
a combinatorial explosion of different kinds of token. A flag on Token tracks
whether a ud-suffix is present, in order to prevent clients from needing to look
at the token's spelling.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152098 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-06 03:21:47 +00:00
Richard Smith 0cc323c6be static_assert: Allow any string-literal as the message, not just a character
string literal, and adjust the diagnostic code to match. This also causes us
to escape any control characters in the message.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152069 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-05 23:20:05 +00:00