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

1330 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 27766d2501 Improve diagnostics for typo correction via Sema::ClassifyName(), by
looking at the context and the correction and using a custom
diagnostic. Also, enable some Fix-It tests that were somewhat lamely
disabled.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130283 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-27 03:47:06 +00:00
Fariborz Jahanian c1a0a73c1f Add ms_struct attribute on record typee
(and ignore it for now) - wip.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130224 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-26 17:54:40 +00:00
Argyrios Kyrtzidis 865dd8c8fe 'extern' variables in functions don't shadow externs in global scope. Fixes rdar://8883302, this time for C++ as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130157 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-25 21:39:50 +00:00
Douglas Gregor ec385cf3c7 When Sema::ClassifyName() finds an invalid ivar reference, return an
invalid expression rather than the far-more-generic "error". Fixes a
mild regression in error recovery uncovered by the GCC testsuite.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130128 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-25 15:05:41 +00:00
Douglas Gregor 312eadb832 Implement a new identifier-classification scheme where Sema
performs name lookup for an identifier and resolves it to a
type/expression/template/etc. in the same step. This scheme is
intended to improve both performance (by reducing the number of
redundant name lookups for a given identifier token) and error
recovery (by giving Sema a chance to correct type names before the
parser has decided that the identifier isn't a type name). For
example, this allows us to properly typo-correct type names at the
beginning of a statement:

t.c:6:3: error: use of undeclared identifier 'integer'; did you mean
'Integer'?
  integer *i = 0;
  ^~~~~~~
  Integer
t.c:1:13: note: 'Integer' declared here
typedef int Integer;
            ^


Previously, we wouldn't give a Fix-It because the typo correction
occurred after the parser had checked whether "integer" was a type
name (via Sema::getTypeName(), which isn't allowed to typo-correct)
and therefore decided to parse "integer * i = 0" as an expression. By
typo-correcting earlier, we typo-correct to the type name Integer and
parse this as a declaration. 

Moreover, in this context, we can also typo-correct identifiers to
keywords, e.g.,

t.c:7:3: error: use of undeclared identifier 'vid'; did you mean
'void'?
  vid *p = i;
  ^~~
  void

and recover appropriately.

Note that this is very much a work-in-progress. The new
Sema::ClassifyName is only used for expression-or-declaration
disambiguation in C at the statement level. The next steps will be to
make this work for the same disambiguation in C++ (where
functional-style casts make some trouble), then push it
further into the parser to eliminate more redundant name lookups.

Fixes <rdar://problem/7963833> for C and starts us down the path of
<rdar://problem/8172000>.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130082 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-24 05:37:28 +00:00
Francois Pichet d4a0caf78e Correctly emit a diagnostic for multiple templated function definitions in -flate-template-parsing mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130030 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-22 23:20:44 +00:00
Francois Pichet 8387e2a41e Add -fdelayed-template-parsing option. Using this option all templated function definitions are parsed at the end of the translation unit only if it is required by an actual instantiation. As such all the symbols of the TU are available during name lookup.
Using this flag is necessary for compatibility with Microsoft template code.
This also provides some parsing speed improvement.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130022 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-22 22:18:13 +00:00
Francois Pichet 4bada2e3f2 Do not return true from MergeFunctionDecl for a warn_static_non_static warning in Microsoft mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130010 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-22 19:50:06 +00:00
Chandler Carruth cfe38c4db4 I concur with DPG here. This does indeed apply in 0x mode. Added test
cases that demonstrates exactly why this does indeed apply in 0x mode.

If isPOD is currently broken in 0x mode, we should fix that directly
rather than papering over it here.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130007 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-22 19:01:39 +00:00
Francois Pichet cf320c6388 For consistency, change suffix from war_ to warn_ for some Microsoft warnings I introduced lately.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129986 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-22 08:25:24 +00:00
Francois Pichet 2e510a0c0f Downgrade error "static declaration of 'foo' follows non-static declaration" to a warning in Microsoft mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129985 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-22 08:14:00 +00:00
Daniel Dunbar db57a4cdb0 ADT/Triple: Switch to using .isOSDarwin() predicate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129823 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-19 21:43:27 +00:00
Richard Smith 162e1c1b48 Support for C++11 (non-template) alias declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129567 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-15 14:24:37 +00:00
Richard Smith ad762fcdc1 Add support for C++0x's range-based for loops, as specified by the C++11 draft standard (N3291).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129541 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-14 22:09:26 +00:00
Francois Pichet 3441a520c6 Still not used to put the * next to the variable name.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129426 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-13 02:44:57 +00:00
Francois Pichet 6943e9befe In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal to the type of one of the base classes then downgrade the missing typename error to a warning. Up to now this is the only case I found where MSVC doesn't require "typename" at class scope. Really strange!
This fixes 1 error when parsing the MSVC 2008 header files.
Example:

template<class T> class A {
public:
  typedef int TYPE;
};
template<class T> class B : public A<T> {
public:
  A<T>::TYPE a; // no typename required because A<T> is a base class.
};


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129425 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-13 02:38:49 +00:00
Eli Friedman a49218e17b PR8369: make __attribute((regparm(0))) work correctly. Original patch by
pageexec@freemail.hu, tweaks by me.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129206 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-09 08:18:08 +00:00
John Wiegley 429bb27699 Use ExprResult& instead of Expr *& in Sema
This patch authored by Eric Niebler.

Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr
pointers as in/out parameters (Expr *&).  This is especially true for the
routines that apply implicit conversions to nodes in-place.  This design is
workable only as long as those conversions cannot fail.  If they are allowed
to fail, they need a way to report their failures.  The typical way of doing
this in clang is to use an ExprResult, which has an extra bit to signal a
valid/invalid state.  Returning ExprResult is de riguour elsewhere in the Sema
interface.  We suggest changing the Expr *& parameters in the Sema interface
to ExprResult &.  This increases interface consistency and maintainability.

This interface change is important for work supporting MS-style C++
properties.  For reasons explained here
<http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>,
seemingly trivial operations like rvalue/lvalue conversions that formerly
could not fail now can.  (The reason is that given the semantics of the
feature, getter/setter method lookup cannot happen until the point of use, at
which point it may be found that the method does not exist, or it may have the
wrong type, or overload resolution may fail, or it may be inaccessible.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129143 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-08 18:41:53 +00:00
Ted Kremenek d40066b0fb Fix PR 9626 (duplicated self-init warnings under -Wuninitialized) with numerous CFG and UninitializedValues analysis changes:
1) Change the CFG to include the DeclStmt for conditional variables, instead of using the condition itself as a faux DeclStmt.
2) Update ExprEngine (the static analyzer) to understand (1), so not to regress.
3) Update UninitializedValues.cpp to initialize all tracked variables to Uninitialized at the start of the function/method.
4) Only use the SelfReferenceChecker (SemaDecl.cpp) on global variables, leaving the dataflow analysis to handle other cases.

The combination of (1) and (3) allows the dataflow-based -Wuninitialized to find self-init problems when the initializer
contained control-flow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128858 91177308-0d34-0410-b5e6-96231b3b80d8
2011-04-04 23:29:12 +00:00
Francois Pichet b613cd6862 Accept __declspec(dllimport) for function defined at class scope in Microsoft mode.
This fixes a bunch of errors when compiling MSVC header files with the -DDLL flag.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128457 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-29 10:39:17 +00:00
Chandler Carruth a7689efa25 Diagnose uninitialized uses of a variable within its own initializer.
This is basically the same idea as the warning on uninitialized uses of
fields within an initializer list. As such, it is on by default and
under -Wuninitialized.

Original patch by Richard Trieu, with some massaging from me on the
wording and grouping of the diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128376 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-27 09:46:56 +00:00
John McCall 379246d29b Don't warn about the 'extern' in 'extern "C"' on a tag decl. This is
usually useless, but not always.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128326 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-26 02:09:52 +00:00
Anders Carlsson 2c3ee54e51 Get rid of handling of the 'explicit' keyword from class-head. We still parse it though, although that will change shortly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128277 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-25 14:31:08 +00:00
Douglas Gregor 1d2de76c75 Minor fix in the injection of labels, since we want to look at the redeclaration context of each declaration in the identifier chain. Should fix Linux self-host
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128210 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-24 14:35:16 +00:00
John McCall 0b7e678a11 Insomniac refactoring: change how the parser allocates attributes so that
AttributeLists do not accumulate over the lifetime of parsing, but are
instead reused.  Also make the arguments array not require a separate
allocation, and make availability attributes store their stuff in
augmented memory, too.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128209 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-24 11:26:52 +00:00
John McCall ac4df2454d Warn about unused declaration-specifiers on tag declarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128118 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 23:00:04 +00:00
John McCall 850d3b304b Apply Jonathan Sauer's proposed solution to PR9519. Thanks!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128075 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-22 07:16:37 +00:00
Abramo Bagnara b0a2fcc1e9 Defined friend functions are *implicitly* inlined, unless the inline specifier occurs explicitly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127877 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-18 15:21:59 +00:00
Abramo Bagnara 7f0a915eb5 Fixed inconsistency when adding TemplateParameterListsInfo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127876 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-18 15:16:37 +00:00
Richard Smith a085da8624 Fix PR9488: 'auto' type substitution can fail (for instance, if it creates a reference-to-void type). Don't crash if it does.
Also fix an issue where type source information for the resulting type was being lost.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127811 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-17 16:11:59 +00:00
Douglas Gregor eef7ac5837 Detect attempts to provide a specialization of a function within a
dependent scope and produce an error (rather than crashing). Fixes PR8979.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127749 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-16 19:27:09 +00:00
Douglas Gregor 250e7a74d5 When we're inserting a synthesized label declaration for a
forward-looking "goto" statement, make sure to insert it *after* the
last declaration in the identifier resolver's declaration chain that
is either outside of the function/block/method's scope or that is
declared in that function/block/method's specific scope. Previously,
we could end up inserting the label ahead of declarations in inner
scopes, confusing C++ name lookup.

Fixes PR9491/<rdar://problem/9140426> and <rdar://problem/9135994>.

Note that the crash-on-invalid PR9495 is *not* fixed. That's a
separate issue.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127737 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-16 16:39:03 +00:00
Douglas Gregor 7cbc558ffd When synthesizing a label declaration based on a goto statement that
cannot yet be resolved, be sure to push the new label declaration into
the right place within the identifier chain. Otherwise, name lookup in
C++ gets confused when searching for names that are lexically closer
than the label. Fixes PR9463.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127623 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-14 21:19:51 +00:00
Sebastian Redl 8999fe1bc3 Make deallocation functions implicitly noexcept in C++0x.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127596 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-14 18:08:30 +00:00
Sebastian Redl 60618fa7f8 Propagate the new exception information to FunctionProtoType.
Change the interface to expose the new information and deal with the enormous fallout.
Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications.
Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127537 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-12 11:50:43 +00:00
Abramo Bagnara c57c17dced Avoid do drop outer template parameter lists on the floor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127404 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-10 13:28:31 +00:00
Daniel Dunbar 975cc644d5 Revert r127206 "Detect attempts to provide a specialization of a function within
a...", it appears to cause us to reject various valid codes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127373 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-09 23:24:34 +00:00
Abramo Bagnara ba877adeb4 Fixed InnerLocStart.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127330 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-09 14:09:51 +00:00
Fariborz Jahanian 02b0d651ec Warn on usage of unavailable objc 'class' in
varienty of cases. // rdar://9092208


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127257 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-08 19:12:46 +00:00
Douglas Gregor f52516038a Teach libclang's token-annotation logic about context-sensitive
keywords for Objective-C+ and C++0x. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127253 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-08 17:10:18 +00:00
Abramo Bagnara a2026c96d3 Fixed source range for StaticAssertDecl and LinkageSpecDecl. Fixed source range for declarations using postfix types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127251 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-08 16:41:52 +00:00
Abramo Bagnara ff676cb48f Fixed source range for all DeclaratorDecl's.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127225 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-08 08:55:46 +00:00
Douglas Gregor db93fdee6c Detect attempts to provide a specialization of a function within a
dependent scope and produce an error (rather than crashing). Fixes PR8979.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127206 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-08 02:04:14 +00:00
Argyrios Kyrtzidis d97cec3deb g++ is more permissive regarding flexible arrays.
It will accept flexible array in union and also as the sole element of a struct/class.

Fixes rdar://9065507.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127171 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-07 20:04:04 +00:00
Douglas Gregor cc20945c78 Support explicit template specialization and instantiation for members
of a C++0x inline namespace within enclosing namespaces, as noted in
C++0x [namespace.def]p8.

Fixes <rdar://problem/9006349>, a libc++ failure where Clang was
rejected an explicit specialization of std::swap (since libc++ puts it
into an inline, versioned namespace std::__1).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127162 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-07 16:54:27 +00:00
Abramo Bagnara a868c3799b Completed source ranges fixes for all classes inheriting from TypeDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127120 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-06 16:09:14 +00:00
Abramo Bagnara 344577e6b5 Fixed TypedefDecl and TemplateTypeParameter source range.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127119 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-06 15:48:19 +00:00
Sebastian Redl 6e5d319b67 Propagate new-style exception spec information to Declarator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127111 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-05 22:42:13 +00:00
Douglas Gregor 26cd44da98 When diagnostics are suppressed (e.g., because of code completion), don't trigger the ExprTemplates.empty() check at the end of a function body
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127046 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-04 23:08:02 +00:00
Douglas Gregor cb710a4df5 Diagnose destructor templates. Fixes PR7904.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127042 91177308-0d34-0410-b5e6-96231b3b80d8
2011-03-04 22:45:55 +00:00