summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaStmtAsm.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-43/+43
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Remove trailing spaceFangrui Song2018-07-301-1/+1
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* Re-land "[Sema] Make getCurFunction() return null outside function parsing"Reid Kleckner2018-03-121-1/+1
| | | | | | | | | | | | | | This relands r326965. There was a null dereference in typo correction that was triggered in Sema/diagnose_if.c. We are not always in a function scope when doing typo correction. The fix is to add a null check. LLVM's optimizer made it hard to find this bug. I wrote it up in a not-very-well-editted blog post here: http://qinsb.blogspot.com/2018/03/ub-will-delete-your-null-checks.html llvm-svn: 327334
* Revert "[Sema] Make getCurFunction() return null outside function parsing"Reid Kleckner2018-03-081-1/+1
| | | | | | | | | | This reverts r326965. It seems to have caused repeating test failures in clang/test/Sema/diagnose_if.c on some buildbots. I cannot reproduce the problem, and it's not immediately obvious what the problem is, so let's revert to green. llvm-svn: 326974
* [Sema] Make getCurFunction() return null outside function parsingReid Kleckner2018-03-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Before this patch, Sema pre-allocated a FunctionScopeInfo and kept it in the first, always present element of the FunctionScopes stack. This meant that Sema::getCurFunction would return a pointer to this pre-allocated object when parsing code outside a function body. This is pretty much always a bug, so this patch moves the pre-allocated object into a separate unique_ptr. This should make bugs like PR36536 a lot more obvious. As you can see from this patch, there were a number of places that unconditionally assumed they were always called inside a function. However, there are also many places that null checked the result of getCurFunction(), so I think this is a reasonable direction. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44039 llvm-svn: 326965
* [X86][MS-InlineAsm] Extended support for variables / identifiers on memory / ↵Coby Tayree2017-09-291-28/+20
| | | | | | | | | | | immediate expressions Allow the proper recognition of Enum values and global variables inside ms inline-asm memory / immediate expressions, as they require some additional overhead and treated incorrect if doesn't early recognized. supersedes D33278, D35774 Differential Revision: https://reviews.llvm.org/D37413 llvm-svn: 314494
* [clang][SemaStmtAsm] small refactoring, NFC.Coby Tayree2017-09-101-3/+5
| | | | llvm-svn: 312882
* [X86][Ms-InlineAsm] Extend MS Dot operator to accept "this" + struct/class ↵Coby Tayree2017-08-091-8/+19
| | | | | | | | | | | pointers aliases MS InlineAsm Dot operator accepts "Bases" such as "this" (cpp) and class/struct pointer typedef. This patch enhance its implementation with this behavior. Differential Revision: https://reviews.llvm.org/D36450 llvm-svn: 310472
* Revert "This patch enables the usage of constant Enum identifiers within ↵Eric Christopher2017-07-251-16/+6
| | | | | | | | Microsoft style inline assembly statements." as it is causing msan failures. This reverts commits r308985 and r308965 llvm-svn: 309004
* This patch enables the usage of constant Enum identifiers within Microsoft ↵Matan Haroush2017-07-251-6/+16
| | | | | | | | | | style inline assembly statements. Differential Revision: https://reviews.llvm.org/D33277 https://reviews.llvm.org/D33278 llvm-svn: 308965
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-031-0/+1
| | | | llvm-svn: 304651
* [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped EnumFaisal Vali2017-04-011-2/+3
| | | | | | | | - also replace direct equality checks against the ConstantEvaluated enumerator with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17. - update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed. llvm-svn: 299316
* Fix build error caused by r290539.Marina Yatsina2016-12-261-3/+2
| | | | llvm-svn: 290541
* [inline-asm]No error for conflict between inputs\outputs and clobber listMarina Yatsina2016-12-261-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | According to extended asm syntax, a case where the clobber list includes a variable from the inputs or outputs should be an error - conflict. for example: const long double a = 0.0; int main() { char b; double t1 = a; __asm__ ("fucompp": "=a" (b) : "u" (t1), "t" (t1) : "cc", "st", "st(1)"); return 0; } This should conflict with the output - t1 which is st, and st which is st aswell. The patch fixes it. Commit on behald of Ziv Izhar. Differential Revision: https://reviews.llvm.org/D15075 llvm-svn: 290539
* Address review feedback by adding comments about ${:uid}Reid Kleckner2016-12-071-3/+5
| | | | llvm-svn: 288868
* Use ${:uid} to generate unique MS asm labels, not {:uid}Reid Kleckner2016-11-291-1/+1
| | | | llvm-svn: 288093
* [MS] Mangle a unique ID into all MS inline asm labelsReid Kleckner2016-11-281-7/+5
| | | | | | | | | | | | This solves PR23715 in a way that is compatible with LTO. MSVC supports jumping to source-level labels and between inline asm blocks, but we don't. Also revert the old solution, r255201, which was to mark these calls as noduplicate. llvm-svn: 288059
* [NFC] Header cleanupMehdi Amini2016-07-181-2/+1
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Avoid using LookupResult's implicit copy ctor and assignment operator to ↵Marina Yatsina2016-03-161-11/+9
| | | | | | | | | | | | | avoid warnings The purpose of this patch is to keep the same functionality without using LookupResult's implicit copy ctor and assignment operator, because they cause warnings when -Wdeprecated is passed. This patch is meant to help the following review: http://reviews.llvm.org/D18123. The functionality is covered by the tests in my original commit (255890) The test case in this patch was added to test a bug caught in the review of the first version of this fix. Differential Revision: http://reviews.llvm.org/D18175 llvm-svn: 263630
* Remove an unused parameterDavid Majnemer2016-01-051-4/+1
| | | | | | No functionality change is intended llvm-svn: 256797
* [ms-inline-asm] Handle dependent identifiers in inline asmDavid Majnemer2016-01-041-4/+13
| | | | | | | | | Build up a dependent expression for MS-style inline assembly if the identifier's type is dependent. This fixes PR26001. llvm-svn: 256795
* [ms inline asm] Add support for label names with '$' charsMarina Yatsina2015-12-291-1/+9
| | | | | | | | | In MS inline asm syntax a label with '$' char produces an error, while in AT&T it does not. In AT&T inline asm syntax Clang escapes the '$' char and replaces it with "$$". Adopted same approach for MS syntax. Differential Revision: http://reviews.llvm.org/D15795 llvm-svn: 256545
* 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
OpenPOWER on IntegriCloud