Commit Graph

352 Commits

Author SHA1 Message Date
Richard Smith 10876ef571 Implement C++11 semantics for [[noreturn]] attribute. This required splitting
it apart from [[gnu::noreturn]] / __attribute__((noreturn)), since their
semantics are not equivalent (for instance, we treat [[gnu::noreturn]] as
affecting the function type, whereas [[noreturn]] does not).

llvm-svn: 172691
2013-01-17 01:30:42 +00:00
Dmitri Gribenko f857950d39 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

llvm-svn: 172323
2013-01-12 19:30:44 +00:00
Hal Finkel 6134a6e7b8 Remove the unused Parser::ParseTranslationUnit function
Parser::ParseTranslationUnit is now dead because the loop over
ParseTopLevelDecl is in ParseAST.

llvm-svn: 172005
2013-01-09 21:49:51 +00:00
Richard Smith 89645bc888 s/CXX0X/CXX11/g, except for __GNU_EXPERIMENTAL_CXX0X__, and update a few nearby 'C++0x' comments.
llvm-svn: 171372
2013-01-02 12:01:23 +00:00
Richard Smith 2bf7fdb723 s/CPlusPlus0x/CPlusPlus11/g
llvm-svn: 171367
2013-01-02 11:42:31 +00:00
Rafael Espindola db7325e56e Minor cleanup.
DS parameter  has a default (null) value anyway, so there's no need for an
if/else here.
Patch by Nikola Smiljanić.

llvm-svn: 171210
2012-12-29 01:09:46 +00:00
Douglas Gregor c50d4924eb Use @import rather than @__experimental_modules_import, since the
latter is rather a mess to type.

llvm-svn: 169919
2012-12-11 22:11:52 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Nico Weber d0b91de8c6 Move PrettyStackTraceParserEntry to ParseAST.cpp
r128056 moved PrettyStackTraceParserEntry construction from Parser.h
to ParseAST.cpp, so there's no need to keep this class in a header.

llvm-svn: 168731
2012-11-27 21:57:34 +00:00
Andy Gibbs a8df57a962 Made the "expected string literal" diagnostic more expressive
llvm-svn: 168267
2012-11-17 19:16:52 +00:00
David Blaikie 0da2fa3561 PR12713 - crash on invalid due to unmatched parens in decltype
llvm-svn: 167547
2012-11-07 19:08:05 +00:00
Douglas Gregor d612566385 Have the parser initialize Sema before it consumes the first
token. This is important because the first token could actually be
after an #include that triggers a module import, which might use
either Sema or the AST consumer before it would have been initialized.

llvm-svn: 167423
2012-11-05 23:58:27 +00:00
Argyrios Kyrtzidis 3a6c8141f9 Decouple code-completion for the SkipFunctionBodies frontend option and
add a test to make sure code-completion skips bodies.

llvm-svn: 167141
2012-10-31 17:29:22 +00:00
Chris Lattner d5705d1b1c Currently the initial value of Tok is dependent an the stack contents
and could cause the Parser to crash on the first ConsumeToken().

Patcy by Bas van den Berg!

llvm-svn: 166891
2012-10-27 19:49:20 +00:00
Mahesha S 19a429e7e6 Reverted back the changes made in 166868 and in 166869
llvm-svn: 166871
2012-10-27 10:44:42 +00:00
Mahesha S 5d61097dd9 Feature:
OpenMP support.

Sub-Feature:
  Support for "#pragma omp ..." registration with
  Preprocessor.

Files Changed/Added:
  * include/clang/Basic/DiagnosticGroups.td (C)
  * include/clang/Basic/DiagnosticParseKinds.td (C)
  * include/clang/Basic/TokenKinds.def (C)
  * include/clang/Parse/Parser.h (C)
  * lib/Parse/Parser.cpp (C)

Test Cases Changed/Added:
  * test/Preprocessor/pragma_omp.c (A)
  * test/Preprocessor/pragma_omp_ignored_warning.c (A)

llvm-svn: 166869
2012-10-27 09:05:45 +00:00
Eli Friedman 68be1649ee Permanently end the whole "pragma got handled by the parser too early"
mess by handling all pragmas which the parser touches uniformly.
<rdar://problem/12248901>, etc.

llvm-svn: 165195
2012-10-04 02:36:51 +00:00
Richard Smith 0875c53239 If a comma operator is followed by a token which unambiguously indicates the
start of a statement or the end of a compound-statement, diagnose the comma as
a typo for a semicolon. Patch by Ahmed Bougacha! Additional test cases and
minor refactoring by me.

llvm-svn: 164085
2012-09-18 00:52:05 +00:00
Benjamin Kramer cc4c49dd63 Now that ASTMultiPtr is nothing more than a array reference, make it a MutableArrayRef.
This required changing all get() calls to data() and using the simpler constructors.

llvm-svn: 162501
2012-08-23 23:38:35 +00:00
Benjamin Kramer f062343889 Remove ASTOwningVector, it doesn't own anything and provides no value over SmallVector.
llvm-svn: 162492
2012-08-23 22:51:59 +00:00
Benjamin Kramer 62b95d88dc Rip out remnants of move semantic emulation and smart pointers in Sema.
These were nops for quite a while and only lead to confusion. ASTMultiPtr
now behaves like a proper dumb array reference.

llvm-svn: 162475
2012-08-23 21:35:17 +00:00
Dmitri Gribenko adba9be7c5 Fix a bunch of -Wdocumentation warnings.
llvm-svn: 162452
2012-08-23 17:58:28 +00:00
Richard Smith 4f605aff7f PR41111, PR5925, PR13210: Teach tentative parsing to annotate identifiers and
nested names as id-expressions, using the annot_primary_expr annotation, where
possible. This removes some redundant lookups, and also allows us to
typo-correct within tentative parsing, and to carry on disambiguating past an
identifier which we can determine will fail lookup as both a type and as a
non-type, allowing us to disambiguate more declarations (and thus offer
improved error recovery for such cases).

This also introduces to the parser the notion of a tentatively-declared name,
which is an identifier which we *might* have seen a declaration for in a
tentative parse (but only if we end up disambiguating the tokens as a
declaration). This is necessary to correctly disambiguate cases where a
variable is used within its own initializer.

llvm-svn: 162159
2012-08-18 00:55:03 +00:00
Fariborz Jahanian 5e74a1af6f Removed an unused function I added a while back.
llvm-svn: 161714
2012-08-10 22:28:13 +00:00
Fariborz Jahanian f64b4722eb objective-C++: dalyed parsing of ctors with member
initializer list defined inside an objc class
implementation. wip

llvm-svn: 161699
2012-08-10 21:15:06 +00:00
Fariborz Jahanian 8cecfe9fc9 objective-C++: delayed parsing of member function with
function-try-block occuring in objc's implementation
block. wip.

llvm-svn: 161675
2012-08-10 18:10:56 +00:00
Fariborz Jahanian 712bb81a6d objective-C++: Delayed parsing of most common
member functions defined inside an objc class
implementation. wip.

llvm-svn: 161667
2012-08-10 15:54:40 +00:00
Richard Smith 87f5dc53b2 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.

llvm-svn: 160618
2012-07-23 05:45:25 +00:00
Francois Pichet f5b24e0136 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.

llvm-svn: 160613
2012-07-22 15:10:57 +00:00
Benjamin Kramer 7ca3b7c977 Move helper class into an anonymous namespace.
llvm-svn: 160172
2012-07-13 13:25:11 +00:00
Jordan Rose 12e730c6e3 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).

llvm-svn: 159941
2012-07-09 16:54:53 +00:00
Fariborz Jahanian 97920394c0 Added a new memberfor Parser, to be used soon
for doing delayed parsing of c++ method defined in
objc class implementations.

llvm-svn: 159792
2012-07-06 00:42:20 +00:00
Fariborz Jahanian 8de7955f35 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.

llvm-svn: 159772
2012-07-05 19:34:20 +00:00
Fariborz Jahanian 8a369a82d5 Obj-C++11 parser: fix broken parsing of c-function
defined in class implementations.

llvm-svn: 159691
2012-07-03 22:54:28 +00:00
Fariborz Jahanian f30f6ac7b9 Obj-C++11 parser: turn off buffering of
c-function defined in objc class
implementation for now.

llvm-svn: 159690
2012-07-03 22:29:23 +00:00
Fariborz Jahanian 577574ab88 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

llvm-svn: 159626
2012-07-02 23:37:09 +00:00
Douglas Gregor 1edf57639a Support the use of "=delete" and "=default" with delayed template
parsing. Fixes <rdar://problem/11700604>.

llvm-svn: 159380
2012-06-28 21:43:01 +00:00
Alexis Hunt 6aa9beef50 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.

llvm-svn: 159072
2012-06-23 05:07:58 +00:00
Dmitri Gribenko 17e147fa9d Unbreak GCC build: GCC doesn't like clang::Parser::CommentHandler and class clang::CommentHandler to have same name.
llvm-svn: 158780
2012-06-20 01:06:08 +00:00
Dmitri Gribenko aab8383a2b 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

llvm-svn: 158771
2012-06-20 00:34:58 +00:00
Douglas Gregor 91c25eadea 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).

llvm-svn: 158111
2012-06-06 21:18:07 +00:00
Benjamin Kramer d1d76b2da7 Remove unused private member variables found by clang's new -Wunused-private-field.
llvm-svn: 158086
2012-06-06 17:32:50 +00:00
Jordan Rose ccf43ca05c 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>

llvm-svn: 158085
2012-06-06 17:25:21 +00:00
Richard Trieu 2f7dc46a58 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.

llvm-svn: 156934
2012-05-16 19:04:59 +00:00
Richard Smith b71e73243b 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.)

llvm-svn: 156786
2012-05-14 22:43:34 +00:00
Richard Smith 45855df4c6 Recover properly if a class member declaration starts with a scope specifier
or template-id which can't be parsed.

llvm-svn: 156468
2012-05-09 08:23:23 +00:00
Douglas Gregor 25c1609648 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>.

llvm-svn: 155988
2012-05-02 14:34:16 +00:00
Chris Lattner 02f1b61849 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 :)

llvm-svn: 155759
2012-04-28 16:12:17 +00:00
Chad Rosier e38c006049 Typo.
llvm-svn: 155596
2012-04-25 22:51:41 +00:00
Benjamin Kramer 1e6b6060f9 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.

llvm-svn: 154743
2012-04-14 12:14:03 +00:00