summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmtAsm.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Split RequireCompleteType into a function that actually requires that the typeRichard Smith2015-12-181-1/+2
| | | | | | | | | | | | | | | | | | | is complete (with an error produced if not) and a function that merely queries whether the type is complete. Either way we'll trigger instantiation if necessary, but only the former will diagnose and recover from missing module imports. The intent of this change is to prevent a class of bugs where code would call RequireCompleteType(..., 0) and then ignore the result. With modules, we must check the return value and use it to determine whether the definition of the type is visible. This also fixes a debug info quality issue: calls to isCompleteType do not trigger the emission of debug information for a type in limited-debug-info mode. This allows us to avoid emitting debug information for type definitions in more cases where we believe it is safe to do so. llvm-svn: 256049
* [ms-inline-asm] Add support for composite structs in MS inline asmMarina Yatsina2015-12-171-27/+39
| | | | | | | | Add MS inline asm support for structs that contain fields that are also structs. Differential Revision: http://reviews.llvm.org/D15578 llvm-svn: 255890
* Use ArrayRef and MutableArrayRef instead of a pointer and size. NFCCraig Topper2015-10-211-2/+2
| | | | llvm-svn: 250876
* Fix assertion in inline assembler IR genAlexander Musman2015-09-211-0/+15
| | | | | | | Several inputs may not refer to one output constraint in inline assembler insertions, clang was failing on assertion on such test case. llvm-svn: 248158
* Add a new frontend warning for referencing members from the handler of a ↵Aaron Ballman2015-09-011-1/+1
| | | | | | | | constructor or destructor function-try-block, which is UB in C++. This corresponds to the CERT secure coding rule ERR53-CPP. llvm-svn: 246548
* [CUDA] Check register names on appropriate side of cuda compilation only.Artem Belevich2015-08-271-6/+10
| | | | | | Differential Revision: http://reviews.llvm.org/D11950 llvm-svn: 246193
* [ms-inline-asm] Add field access to MS inline asm identifier lookupReid Kleckner2015-08-261-7/+55
| | | | | | | | | | | | | | Now we can parse code like this: struct A { int field; }; int f(A o) { __asm mov eax, o.field } Fixes PR19117. llvm-svn: 246088
* Additional fix for PR14269: Crash on vector elements / global register vars ↵Andrey Bokhanko2015-08-031-14/+39
| | | | | | | | | | in inline assembler. Compiler crashed when vector elements / global register vars were used in inline assembler with "m" restriction. This patch fixes this. Differential Revision: http://reviews.llvm.org/D10476 llvm-svn: 243870
* [X86, inlineasm] Improve analysis of x,Y0,Yi,Ym,Yt,L,e,Z,s asm constraints ↵Alexey Bataev2015-07-201-2/+1
| | | | | | | | | (patch by Alexey Frolov) Improve Sema checking of 9 existing inline asm constraints (‘x’, ‘Y*’, ‘L’, ‘e’, ‘Z’, ‘s’). Differential Revision: http://reviews.llvm.org/D10536 llvm-svn: 242665
* Fixed 22941: Integer template parameter as immediate 'I' expectes an integer ↵Sunil Srivastava2015-07-141-11/+13
| | | | | | | | | constant Basically fixed premature testing of integer constraints during template parsing Reviewed at http://reviews.llvm.org/D10452 llvm-svn: 242175
* Fix for PR14269: Clang crashes when a bit field is used as inline assemblerAlexander Musman2015-06-051-0/+16
| | | | | | | | | | | | input / output with memory constraint. One generally can't get address of a bit field, so the general solution is to error on such cases. GCC does the same. Patch by Andrey Bokhanko Differential Revision: http://reviews.llvm.org/D10086 llvm-svn: 239153
* [cuda] Ignore "TLS unsupported by target" errors for host variables during ↵Artem Belevich2015-04-271-10/+2
| | | | | | | | | | | | | | | | device compilation. During device-side CUDA compilation clang currently complains about all TLS variables, regardless of whether they are __host__ or __device__. This patch suppresses "TLS unsupported" errors for host variables during device compilation and for device variables during host compilation. Differential Revision: http://reviews.llvm.org/D9269 llvm-svn: 235907
* Ignore device-side asm constraint errors while compiling CUDA code for host ↵Artem Belevich2015-03-191-3/+16
| | | | | | | | and vice versa. Differential Revision: http://reviews.llvm.org/D8392 llvm-svn: 232747
* [inlineasm] Fix an incorrect warning about register constraint and modifier.Akira Hatanaka2015-02-041-23/+13
| | | | | | | | | | | | | | | Previously, when the following piece of code was compiled, clang would incorrectly warn that the size of "wide_two" does not match register size specified by the constraint and modifier": long wide_two = two; asm ("%w0 %1" : "+r" (one), "+r"(wide_two)); This was caused by a miscalculation of ConstraintIdx in Sema::ActOnGCCAsmStmt. This commit fixes PR21270 and rdar://problem/18668354. llvm-svn: 228089
* Diagnose CXX 'this' pointer reference in funcs with naked attrWeiming Zhao2015-02-031-0/+6
| | | | | | | | | Clang asserts for this pointer reference in asms of naked functions. This patch diagnoses if this pointer reference is used. Differential Revision: http://reviews.llvm.org/D7329 llvm-svn: 228052
* When reporting constraints that should be constant, the type doesn'tJoerg Sonnenberger2015-01-221-3/+2
| | | | | | really help. Improve diagnostics. llvm-svn: 226863
* Sema: analyze I,J,K,M,N,O constraintsSaleem Abdulrasool2015-01-061-0/+14
| | | | | | | | | | Add additional constraint checking for target specific behaviour for inline assembly constraints. We would previously silently let all arguments through for these constraints. In cases where the constraints were violated, we could end up failing to select instructions and triggering assertions or worse, silently ignoring instructions. llvm-svn: 225244
* Sema: Permit array l-values in asm output operandsDavid Majnemer2014-12-291-0/+3
| | | | | | | | GCC permits array l-values in asm output operands even though they aren't modifiable l-values. We used to permit it but this behavior regressed in r224916. llvm-svn: 224918
* Sema: Only permit permit modifiable l-values as asm output paramsDavid Majnemer2014-12-291-14/+42
| | | | | | | | | | Functions are l-values in C++ but shouldn't be available as output parameters in inline assembly. Neither should overloaded function l-values. This fixes PR21949. llvm-svn: 224916
* Sema: Forbid inconsistent constraint alternativesDavid Majnemer2014-12-291-0/+20
| | | | | | Verify that asm constraints have the same number of alternatives llvm-svn: 224911
* Parse: Concatenated string literals should be verified in inline asmDavid Majnemer2014-12-111-12/+4
| | | | | | | | | | While we would correctly handle asm("foo") and reject asm(L"bar"), we weren't careful to handle cases where an ascii literal could be concatenated with a wide literal. This fixes PR21822. llvm-svn: 223992
* ms-inline-asm: Correctly mark MS inline ASM labels as usedEhsan Akhgari2014-10-081-1/+4
| | | | | | | | | | | | | | Summary: This fixes PR21155. Test Plan: The patch includes a test. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5619 llvm-svn: 219322
* Disallow using function parameters in extended asm inputs or outputs in ↵Hans Wennborg2014-10-081-11/+36
| | | | | | | | | | | | | | naked functions (PR21178) Clang won't emit any prologues for such functions, so it would assert trying to codegen the parameter references. This patch makes Clang check the extended asm inputs and outputs for references to function parameters. Differential Revision: http://reviews.llvm.org/D5640 llvm-svn: 219272
* ms-inline-asm: Scope inline asm labels to functionsEhsan Akhgari2014-09-221-0/+30
| | | | | | | | | | | | | | | | Summary: This fixes PR20023. In order to implement this scoping rule, we piggy back on the existing LabelDecl machinery, by creating LabelDecl's that will carry the "internal" name of the inline assembly label, which we will rewrite the asm label to. Reviewers: rnk Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4589 llvm-svn: 218230
* [X86, inlineasm] Check that the output size is correct for the given constraint.Akira Hatanaka2014-09-181-0/+14
| | | | llvm-svn: 218064
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-061-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases -- that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls wasn't used for anything before this warning it wasn't always set correctly, so this patch also adds a few missing MarkAnyDeclReferenced() calls in various places for TypedefNameDecls. This is made a bit complicated due to local typedefs possibly being used only after their local scope has closed. Consider: template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } Here the typedef in XXX is only used at end-of-translation unit, when YYY in template_fun() gets instantiated. To handle this, typedefs that are unused when their scope exits are added to a set of potentially unused typedefs, and that set gets checked at end-of-TU. Typedefs that are still unused at that point then get warned on. There's also serialization code for this set, so that the warning works with precompiled headers and modules. For modules, the warning is emitted when the module is built, for precompiled headers each time the header gets used. Finally, consider a function using C++14 auto return types to return a local type defined in a header: auto f() { struct S { typedef int a; }; return S(); } Here, the typedef escapes its local scope and could be used by only some translation units including the header. To not warn on this, add a RecursiveASTVisitor that marks all delcs on local types returned from auto functions as referenced. (Except if it's a function with internal linkage, or the decls are private and the local type has no friends -- in these cases, it _is_ safe to warn.) Several of the included testcases (most of the interesting ones) were provided by Richard Smith. (gcc's spelling -Wunused-local-typedefs is supported as an alias for this warning.) llvm-svn: 217298
* Don't allow inline asm statements to reference parameters in naked functionsHans Wennborg2014-09-041-0/+13
| | | | | | Differential Revision: http://reviews.llvm.org/D5183 llvm-svn: 217200
* [AArch64, inline-asm] Improve diagnostic that is printed when the size of aAkira Hatanaka2014-08-221-3/+14
| | | | | | | | | | | | | | | | | variable that has regiser constraint "r" is not 64-bit. General register operands are output using 64-bit "x" register names, regardless of the size of the variable, unless the asm operand is prefixed with the "%w" modifier. This surprises and confuses many users who aren't familiar with aarch64 inline assembly rules. With this commit, a note and fixit hint are printed which tell the users that they need modifier "%w" in order to output a "w" register instead of an "x" register. <rdar://problem/12764785> llvm-svn: 216260
* CodeGen: Let arrays be inputs to inline asmDavid Majnemer2014-07-141-5/+6
| | | | | | | | | | | An array showing up in an inline assembly input is accepted in ICC and GCC 4.8 This fixes PR20201. Differential Revision: http://reviews.llvm.org/D4382 llvm-svn: 212954
* Don't include llvm/MC/MCParser throughout all of SemaAlp Toker2014-06-081-1/+2
| | | | | | Requires LLVM r210417. llvm-svn: 210418
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-2/+2
| | | | llvm-svn: 209812
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-3/+3
| | | | | | takeAs to getAs. llvm-svn: 209800
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-2/+2
| | | | llvm-svn: 209613
* Support field references to struct names and c++11 aliases from inline asm.Nico Weber2014-05-061-1/+3
| | | | | | This is in addition to the existing support for typedefs. llvm-svn: 208053
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-1/+0
| | | | llvm-svn: 207896
* [ms-inline asm] Don't diagnose an empty lookup for inline assmebly. This happenChad Rosier2013-05-241-1/+3
| | | | | | | | | | | | | for labels in inline assembly that aren't in the lookup tables. E.g., __asm { a: jmp a } rdar://13983623 llvm-svn: 182659
* Remove redundant variableDmitri Gribenko2013-05-101-4/+3
| | | | llvm-svn: 181574
* Move parsing of identifiers in MS-style inline assembly intoJohn McCall2013-05-031-285/+47
| | | | | | | | | | | | | | | | | | | | | the actual parser and support arbitrary id-expressions. We're actually basically set up to do arbitrary expressions here if we wanted to. Assembly operands permit things like A::x to be written regardless of language mode, which forces us to embellish the evaluation context logic somewhat. The logic here under template instantiation is incorrect; we need to preserve the fact that an expression was unevaluated. Of course, template instantiation in general is fishy here because we have no way of delaying semantic analysis in the MC parser. It's all just fishy. I've also fixed the serialization of MS asm statements. This commit depends on an LLVM commit. llvm-svn: 180976
* [ms-inline asm] Set the OpDecl to the InlineAsmIdentifierInfo struct.Chad Rosier2013-04-221-0/+1
| | | | | | Part of rdar://13663589 llvm-svn: 180055
* [ms-inline asm] Refactor/clean up the SemaLookup interface. No functionalChad Rosier2013-04-221-23/+13
| | | | | | | change indended. Part of rdar://13663589 llvm-svn: 180027
* [ms-inline asm] The parsing of C++ identifiers is a task of the front-end ↵Chad Rosier2013-04-191-0/+31
| | | | | | | | | | parser, not the asm parser. As such, begin moving the parsing logic in that direction. This patch is just a temporary hack until the real frontend parser can be hooked up. Part of rdar://13663589 llvm-svn: 179882
* Specify that we're parsing ms-style inline assembly.Chad Rosier2013-04-181-1/+1
| | | | llvm-svn: 179762
* Use the ASYContext::getTypeSizeInChars API to cleanup some ugliness, per JohnChad Rosier2013-04-011-5/+3
| | | | | | and Jordan's suggestion. No functional change intendend. llvm-svn: 178507
* Cleanup. No functional change intended.Chad Rosier2013-04-011-18/+17
| | | | llvm-svn: 178481
* Pass the diagnostic in for better error messages.Bill Wendling2013-03-271-8/+6
| | | | llvm-svn: 178120
* Emit an error message instead of crashing when dereferencing an incomplete ↵Bill Wendling2013-03-251-7/+15
| | | | | | | | | | pointer type. If the ASM statement is dereferencing an incomplete pointer type, issue an error instead of crashing. <rdar://problem/12700799> llvm-svn: 177915
* Use RequireCompleteType() instead of isIncompleteType().Bill Wendling2013-03-221-1/+3
| | | | | | | | | | | | isIncompleteType() returns true or false for template types depending on whether the type is instantiated yet. In this context, that's arbitrary. The better way to check for a complete type is RequireCompleteType(). Thanks to Eli Friedman for noticing this! <rdar://problem/12700799> llvm-svn: 177768
* MCParser: Update method names per coding guidelines.Jim Grosbach2013-02-201-1/+1
| | | | | | s/ParseMSInlineAsm/parseMSInlineAsm/ llvm-svn: 175680
* [ms-inline asm] Add an error when trying to compile MS-style inline assemblyChad Rosier2013-01-241-2/+9
| | | | | | | for an unsupported architecture. rdar://13063988 llvm-svn: 173364
* [ms-inline asm] Extend the Sema interface to get the size and length of aChad Rosier2013-01-171-5/+19
| | | | | | | VarDecl. Part of rdar://12576868 llvm-svn: 172742
OpenPOWER on IntegriCloud