Commit Graph

473 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
Richard Smith 945f8d32fd Refactor to call ActOnFinishFullExpr on every full expression. Teach
ActOnFinishFullExpr that some of its checks only apply to discarded-value
expressions. This adds missing checks for unexpanded variadic template
parameter packs to a handful of constructs.

llvm-svn: 172485
2013-01-14 22:39:08 +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
Matt Beaumont-Gay b1e71a7d0c Fix -Wunused-comparison for comparisons in arguments to function-like macros.
Previously, -Wunused-comparison ignored comparisons in both macro bodies and
macro arguments, but we would still emit a -Wunused-value warning for either.
Now we correctly emit -Wunused-comparison for expressions in macro arguments.

Also, add isMacroBodyExpansion to SourceManager, to go along with
isMacroArgExpansion.

llvm-svn: 172279
2013-01-12 00:54:16 +00:00
Fariborz Jahanian 941827931e Provide a better warning when case value overflows.
// rdar://11577384

llvm-svn: 172102
2013-01-10 20:26:42 +00:00
Fariborz Jahanian 8b115b7872 Issue warning when case value is too large to fit
in case condition type. // rdar://11577384.
Test is conditionalized on x86_64-apple triple as
I am not sure if the INT_MAX/LONG_MAX values in the test
will pass this test for other hosts.

llvm-svn: 172016
2013-01-09 23:04:56 +00:00
Richard Smith 2bf7fdb723 s/CPlusPlus0x/CPlusPlus11/g
llvm-svn: 171367
2013-01-02 11:42:31 +00:00
Nico Weber 9dff378a12 ArrayRefize CXXTryStmt.
llvm-svn: 171239
2012-12-29 20:13:03 +00:00
Nico Weber a2a0eb940a ArrayRefize a CompoundStmt constructor.
llvm-svn: 171238
2012-12-29 20:03:39 +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
Dmitri Gribenko d4bc5ac69d Remove redundant (duplicated) check.
llvm-svn: 168293
2012-11-18 22:28:42 +00:00
Abramo Bagnara 598b943410 Fixed LabelDecl source range.
llvm-svn: 165976
2012-10-15 21:07:44 +00:00
Richard Smith a05b3b5435 If the range in a for range statement doesn't have a viable begin/end function,
but can be dereferenced to form an expression which does have viable begin/end
functions, then typo-correct the range, even if something else goes wrong with
the statement (such as inaccessible begin/end or the wrong type of loop
variable).

In order to ensure we recover correctly and produce any followup diagnostics in
this case, redo semantic analysis on the for-range statement outside of the
diagnostic trap, after issuing the typo-correction.

llvm-svn: 164323
2012-09-20 21:52:32 +00:00
Sam Panzer 22a3fe1b9c Clarified diagnostics for range-based for loops with invalid ranges
llvm-svn: 163350
2012-09-06 21:50:08 +00:00
Joao Matos 566359c0bf Revert r163083 per chandlerc's request.
llvm-svn: 163149
2012-09-04 17:49:35 +00:00
Joao Matos c32a7e4d8e Implemented parsing and AST support for the MS __leave exception statement. Also a minor fix to __except printing in StmtPrinter.cpp. Thanks to Aaron Ballman for review.
llvm-svn: 163083
2012-09-02 03:45:41 +00:00
Chris Lattner 6dc7e57d6a don't warn about unused values when the unused value is a statement expression expanded from a macro. This is of dubious utility in general, but is specifically a major issue for the linux kernel. This resolves PR13747.
llvm-svn: 163034
2012-08-31 22:39:21 +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 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
Sam Panzer 0f38443616 Better diagnostics for range-based for loops with bad range types.
The old error message stating that 'begin' was an undeclared identifier
is replaced with a new message explaining that the error is in the range
expression, along with which of the begin() and end() functions was
problematic if relevant.

Additionally, if the range was a pointer type or defines operator*,
attempt to dereference the range, and offer a FixIt if the modified range
works.

llvm-svn: 162248
2012-08-21 00:52:01 +00:00
Chad Rosier 0731affaca [ms-inline asm] Extract AsmStmt handling into a separate file, so as to not
pollute SemaStmt with extraneous asm handling logic.

llvm-svn: 162132
2012-08-17 21:19:40 +00:00
Chad Rosier 2da9d6d6cf [ms-inline asm] Instantiate the MCStreamer as a NullStream. We're parsing
instruction, not emitting them, so a NullStream is fine.

llvm-svn: 162105
2012-08-17 16:38:04 +00:00
Chad Rosier b899c1b417 [ms-inline asm] Comment.
llvm-svn: 162055
2012-08-16 22:47:10 +00:00
Chad Rosier bf17e01fe5 [ms-inline asm] Extract a helper function, getSpelling(). Also use this on
tokens we don't know how to handle; this should aid when debugging.

llvm-svn: 162053
2012-08-16 22:40:32 +00:00
Chad Rosier 50cf25c72d [ms-inline asm] If we don't know how to handle a token then assume this is not a
simple asm.

llvm-svn: 162051
2012-08-16 22:30:02 +00:00
Chad Rosier 3d4b98b4bc [ms-inline asm] Add a helper function, isMSAsmKeyword().
These require special handling, which we don't currently handle.  This is being
put in place to ensure we don't do invalid symbol table lookups or try to parse
invalid assembly.  The test cases just makes sure the latter isn't happening.

llvm-svn: 162050
2012-08-16 22:25:38 +00:00
Sam Panzer 2c4ca0fa7d Removed unused LParenLoc parameter to ActOnCXXForRangeStmt
llvm-svn: 162048
2012-08-16 21:47:25 +00:00
Chad Rosier efb2911664 [ms-inline asm] Perform symbol table lookup on variables. The idea is to use
this information to determine valid MC operands.  This will also be used for
semantic analysis.

llvm-svn: 162043
2012-08-16 19:52:25 +00:00
Chad Rosier 592b90a476 [ms-inline asm] Start tracking which tokens are registers and which are
variables, function or label references.  The former is a potential clobber.
The latter is either an input or an output.  Unfortunately, it's difficult to
test this patch at the moment, but the added test case will eventually do so.

llvm-svn: 162026
2012-08-16 17:10:59 +00:00
Chad Rosier 7dbef3e035 [ms-inline asm] Add inputs and outputs to AST. No functional change.
llvm-svn: 162000
2012-08-16 00:06:53 +00:00
Chad Rosier b32f3d5230 [ms-inline asm] Use a set container to remove redundant clobbers.
llvm-svn: 161991
2012-08-15 21:55:19 +00:00
Chad Rosier 712faa2708 [ms-inline asm] Address a FIXME by computing the number of asm statements when
building the AsmString.

llvm-svn: 161988
2012-08-15 21:08:52 +00:00
Chad Rosier aa7c1cb5f8 [ms-inline asm] MSVC parses multiple __asm statements on a single line as one
statement.  For example,

  if (x)
    __asm out dx, ax  __asm out dx, ax

results in a single inline asm statement (i.e., both "out dx, ax" statements are
predicated on if(x)).

llvm-svn: 161986
2012-08-15 21:03:27 +00:00
Chad Rosier ecf77b56dd [ms-inline asm] Don't emit newlines as these are ignored by the AsmParser
anyways.  Also, simplify some conditional logic.

llvm-svn: 161977
2012-08-15 19:12:42 +00:00
Chad Rosier ad34aef449 [ms-inline asm] Capturing loop-scoped (std::string)Reg with a StringRef is bad.
llvm-svn: 161966
2012-08-15 18:09:18 +00:00
Chad Rosier b6f46c1af9 [ms-inline asm] Add the left brace source location and improve the pretty
printer.  Patch by Enea Zaffanella <zaffanella@cs.unipr.it>.

llvm-svn: 161958
2012-08-15 16:53:30 +00:00
NAKAMURA Takumi 19f29cfc14 clang/lib/Sema/SemaStmt.cpp: Include MCAsmLexer.h to appease msvc to define llvm::AsmToken.
llvm-svn: 161927
2012-08-15 04:19:08 +00:00
Chad Rosier 222ed4b53a [ms-inline asm] Have MC start parsing the asms.
llvm-svn: 161913
2012-08-15 00:42:47 +00:00
Chad Rosier 767a7b9ed0 [ms-inline asm] Remove the last bits of LineEnds.
llvm-svn: 161904
2012-08-14 23:14:45 +00:00
Chad Rosier a6e89aac91 [ms-inline asm] Simplify more logic by using the Token::hasLeadingSpace() and
Token::isAtStartOfLine() APIs.

llvm-svn: 161898
2012-08-14 22:11:17 +00:00
Chad Rosier bba12afe48 [ms-inline asm] Address a potential buffer overflow.
llvm-svn: 161896
2012-08-14 21:48:01 +00:00
Chad Rosier 25e8fe6ae0 [ms-inline asm] Simplify the logic in patchMSAsmString. We no longer need to
track the LineEnds now that single line asm statments aren't merged.

llvm-svn: 161893
2012-08-14 20:58:21 +00:00
Chad Rosier 7459543795 [ms-inline asm] Add a helpful assert.
llvm-svn: 161796
2012-08-13 22:04:09 +00:00
Chad Rosier 162b14f326 [ms-inline asm] Address a potential buffer overflow.
llvm-svn: 161793
2012-08-13 21:35:47 +00:00
Chad Rosier 65a8e0b69f [ms-inline asm] Have patchMSAsmStrings() return a vector or AsmStrings.
The AsmParser expects a single asm instruction, but valid ms-style inline asm
statements may contain  multiple instructions.

This happens with asm blocks

__asm {
  mov ebx, eax
  mov ecx, ebx
}

or when multiple asm statements are adjacent to one another

__asm mov ebx, eax
__asm mov ecx, ebx

and

__asm mov ebx, eax __asm mov ecx, ebx

Currently, asm blocks are not properly handled.

llvm-svn: 161780
2012-08-13 20:32:07 +00:00
Chad Rosier f32302a7d9 [ms-inline asm] PatchMSAsmString() doesn't correctly patch non-simple asm
statements.  Therefore, we can't pass the PatchedAsmString to the AsmParser
and expect things to work.

llvm-svn: 161701
2012-08-10 21:27:11 +00:00
Chad Rosier d6ef704fe4 [ms-inline asm] Fix a memory leak introduced in r161686.
llvm-svn: 161698
2012-08-10 21:06:19 +00:00
Chad Rosier a7020aee00 [ms-inline asm] Add clobbers to AST representation.
llvm-svn: 161686
2012-08-10 19:13:14 +00:00
Chad Rosier 3674ebaa6b [ms-inline asm] Use asserts as these calls are now guarded by identical checks.
llvm-svn: 161676
2012-08-10 18:20:12 +00:00
Chad Rosier 02a8439730 Whitespace.
llvm-svn: 161673
2012-08-10 17:56:09 +00:00