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

80 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner 14943b90d9 Fix PR2020 by recovering by defining an anonymous enum, instead of recovering
by filling in the body of a union with enum constants.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53069 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-03 03:30:58 +00:00
Argyrios Kyrtzidis 07952324dd Add Sema support for C++ classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52956 91177308-0d34-0410-b5e6-96231b3b80d8
2008-07-01 10:37:29 +00:00
Chris Lattner 3ff30c8e6e move some code from all callers of ProcessDeclAttributes into
the implementation of ProcessDeclAttributes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52875 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-29 00:02:00 +00:00
Chris Lattner f2e4bd51aa more attribute refactoring/renaming, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52874 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-28 23:58:55 +00:00
Argyrios Kyrtzidis 53d0ea5f5b Replace CurFunctionDecl and CurMethodDecl with methods getCurFunctionDecl() and getCurMethodDecl() that return the appropriate Decl through CurContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52852 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-28 06:07:14 +00:00
Chris Lattner 6b6b5372f4 move decl attribute processing to a new SemaDeclAttr.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52792 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 18:38:35 +00:00
Chris Lattner 985abd958d Make Declarator::getDeclSpec() return a const reference to avoid
cases where mutation can introduce bugs.  Propagate around 'const'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52772 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 06:49:43 +00:00
Chris Lattner d546fc5f20 add a comment about something that was surprising, at least to me.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52771 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 06:39:41 +00:00
Chris Lattner fca0ddd429 fix a bug handling type attributes in the declspec. declspec processing
used to mutate the attribute list for declspecs when the type was 
converted, breaking the case where one declspec was shared by multiple
declarators.

This fixes rdar://6032532.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52769 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-26 06:27:57 +00:00
Chris Lattner 18ae3cfe2a Don't add isa with @defs only to work around it in the code generator, patch
by David Chisnall. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52597 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 21:37:25 +00:00
Chris Lattner 5a6ddbf295 add parser and sema support for the funny ObjC '@defs' thing.
Patch by David Chisnall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52586 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-21 19:39:06 +00:00
Chris Lattner 4111024be8 Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.
Patch by David Chisnall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52422 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-17 18:05:57 +00:00
Eli Friedman 54ecfce94b Don't crash if we can't find FileEntry info for a typedef, since one
isn't guaranteed to exist. This fixes a crash with conflicting typedefs
coming from stdin.

This also fixes the crash in PR2406, but doesn't completely fix the 
issue; it appears there's something strange about the physical location 
for the definition of int64_t in stdlib.h.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52209 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-11 06:20:39 +00:00
Argyrios Kyrtzidis 7643536c36 -Add DeclChain member to DeclContext.
-ScopedDecls get chained to their DeclContext.
-DeclContext's DeclChain replaces FunctionDecl's DeclChain and EnumDecl's ElementList.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52164 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-10 01:32:09 +00:00
Argyrios Kyrtzidis 39ba4aeca2 -Changes to TagDecl:
Added TagKind enum.
  Added getTagKind() method.
  Added convenience methods: isEnum(), isStruct(), isUnion(), isClass().
-RecordDecl/CXXRecordDecl::Create() accept a TagKind enum instead of a DeclKind one.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52160 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-09 23:19:58 +00:00
Eli Friedman 4caf055b9f Add code to make test/CodeGen/struct-init.c work correctly without the
pointer cast hack currently in isIntegerConstantExpr 
(in lib/AST/Expr.cpp).  Also removes an odd test that even gcc doesn't accept.

The reason the pointer cast hack is relevant here is that it makes Sema 
end up misinterpreting the relevant expression as a null pointer constant.

The reason for this patch is that I plan to remove the pointer cast hack 
sometime soon because it causes strange issues, especially in its 
current form; see my recent email to cfe-dev
"[PATCH] add constant expression evaluation to the AST and fix PR2413".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52120 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-09 05:05:07 +00:00
Nuno Lopes d4cbda6292 implement the alias attirbute (in both Sema and Codegen)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52092 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-08 15:45:52 +00:00
Eli Friedman e6f058fa6d Clean up dead code from SemaInit landing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52054 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-06 19:40:52 +00:00
Eli Friedman 1b76ada683 Re-fix r51907 in a way which doesn't affect valid code. This essentially
moves the check for the invalid construct to a point where it doesn't 
affect other uses of isIntegerConstantExpr, and we can warn properly 
when the extension is used.  This makes it a bit more complicated, but 
it's a lot cleaner.

Steve, please tell me if this check is sufficient to handle the 
relevant system header.  I know it's enough to handle the testcase, but 
I don't know what exactly the original looks like.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51918 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-03 21:01:11 +00:00
Nuno Lopes 9141bee299 fix decl attributes cleaning
this plugs the leak of attributes and also fixes a crash in the test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51862 91177308-0d34-0410-b5e6-96231b3b80d8
2008-06-01 22:53:53 +00:00
Eli Friedman c1cc6dccd4 Allow a pointer implicitly cast to a bool as a constant expression, as
required by the standard (the standard doesn't know anything about 
implicit casts).

Disallow pointers cast to non-integral arithmetic types as constant 
expressions.  This was previously allowed by accident. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51779 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-30 18:14:48 +00:00
Eli Friedman 2742496d75 Don't swap function decls, and add them to the scope as they are
encountered.  Mixing up the decls is unintuitive, and confuses the AST 
destruction code. Fixes PR2360.

Note that there is a need to look up the characteristics and 
declarations of a function associated with a particular name or decl, 
but the original swapping code doesn't solve it properly. 
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-May/001644.html is one 
suggestion for how to fix that.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51584 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-27 05:07:37 +00:00
Eli Friedman 3c0eb160ca Implementation of gcc mode attribute; this is significant because
it fixes PR2204.  Not too much to say about the implementation; it works 
in a similar way to the vector size attribute.

At some point, we need to modify the targets to provide information 
about the appropriate types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51577 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-27 03:33:27 +00:00
Ted Kremenek 2d05c08840 Revert r51498: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=51498&r1=51497&r2=51498&view=diff
Turns out that there are multiple places where a redefinition diagnostic can be emitted.  A cleaner solution (without touching Sema) is to have
the Driver turn off these diagnostics.  (will submit this patch soon)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51502 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 21:28:18 +00:00
Steve Naroff 9547f5938b Remove a diagnostic (temporary hack that will be removed next week).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51498 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-23 20:57:38 +00:00
Eli Friedman 6d1e4b5e7e Patch for PR2350; the issue was tnat we were allowing (with an error)
void f(const void) in one place and rejecting it in another.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51424 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-22 08:54:03 +00:00
Dan Gohman 4f8d123e3e Move getAccessedFieldNo out of lib/AST/Expr.cpp into
lib/CodeGen/CGExpr.cpp and to change include/clang/AST/Attr.h to
use its own enum for visibility types instead of using
llvm::GlobalValue::VisibilityTypes. These changes eliminate
dependencies in the AST library on LLVM's VMCore library.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51398 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-22 00:50:06 +00:00
Eli Friedman 97c0a39113 Fix a couple of bugs found by Neil Booth in the const-ness checking.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51361 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-21 03:39:11 +00:00
Nuno Lopes 1e60e3b526 initialize variable and fix a bunch of test failures
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51326 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 18:03:51 +00:00
Eli Friedman c594b32355 Perform stricter/more accurate checking for C99 constant expressions
in Sema, per discussion on mailing list.  This doesn't cause any changes 
in the test results.  I'll probably add some more tests at some point, 
but it's an open question what we need to accept to be compatible with 
real code.

This doesn't touch the existing isConstantExpr method on Expr; that 
should be addressed somehow eventually (either removed or refined to 
whatever is appropriate).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51318 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-20 13:48:25 +00:00
Eli Friedman c56c977f44 Switch on SemaInit; this makes some code in SemaDecl dead, but I'll give
it a few days to make sure there aren't any significant regressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51273 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-19 20:29:35 +00:00
Steve Naroff 235549c7bd Fix <rdar://problem/5924576> clang -fsyntax-only generates "redefinition" errors when parsing AppKit that gcc does not.
Teach Sema::MergeVarDecl() about __private_extern__.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51005 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-12 22:36:43 +00:00
Argyrios Kyrtzidis 00bc645d15 -Implement proper name lookup for namespaces.
-identifierResolver exposes an iterator interface to get all decls through the scope chain.
-The semantic staff (checking IdentifierNamespace and Doug's checking for shadowed tags were moved out of IdentifierResolver and back into Sema. IdentifierResolver just gives an iterator for all reachable decls of an identifier.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50923 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-09 23:39:43 +00:00
Ted Kremenek 72786e009b Add attribute "format" support for typedefs of function pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50906 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-09 17:36:24 +00:00
Nate Begeman fc58452341 Handle all attributes on a parameter
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50903 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-09 16:56:01 +00:00
Chris Lattner abb5758660 Fix rdar://5921025 a crash on the included testcase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50885 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-09 05:34:49 +00:00
Ted Kremenek c5f551f06c Added initial support for supporting __NSString__ in attribute "format".
Still need to iron out some of the semantics (fixmes are present).
This addresses <rdar://problem/5916348>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50866 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-08 19:43:35 +00:00
Douglas Gregor 6d6eb57225 Diagnose attempts to use C++ default arguments outside of a function declaration
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50799 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-07 04:49:29 +00:00
Chris Lattner 95e2c71181 Fix rdar://5905347 a crash on invalid builtin, due to the
params not getting installed for builtins when synthesized.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50676 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05 22:18:14 +00:00
Chris Lattner 37d1084efc Add support for -Wimplicit-function-declaration, rdar://5907433
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50672 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-05 21:18:06 +00:00
Steve Naroff 0cca749f64 Replace Sema::CheckInitializerListTypes() with a helper class (InitListChecker) that synthesizes implicit InitListExpr's when appropriate (see InitListExpr comments in Expr.h for more details). I also moved the code to SemaInit.cpp, to help reduce clutter in SemaDecl.cpp.
NOTE: This work is incomplete and still fails many tests (as a result, it isn't enabled yet). Nevertheless, I wanted to check it in so I can work on it from home.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50544 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 22:18:59 +00:00
Argyrios Kyrtzidis 93213bb42c Implicitly defined functions were getting the DeclContext of the function where they appeared, causing the bug: http://llvm.org/bugs/show_bug.cgi?id=2266.
Fix it by making implicitly defined functions get the DeclContext of translation unit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50538 91177308-0d34-0410-b5e6-96231b3b80d8
2008-05-01 21:04:16 +00:00
Chris Lattner 2262494248 fix 'var unused' warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50484 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-30 16:04:01 +00:00
Argyrios Kyrtzidis 2d1c5d313c Parsing of namespaces:
-NamespaceDecl for the AST
-Checks for name clashes between namespaces and tag/normal declarations.

This commit doesn't implement proper name lookup for namespaces.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50321 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-27 13:50:30 +00:00
Nuno Lopes 27ae6c6531 initial support for recognizing __transparent_union__ attributes
comments on the ML will follow

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50262 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-25 09:32:00 +00:00
Chris Lattner 9fdf9c6d35 "This patch renames
DeclContext *CtxDecl -> DeclContext *DeclCtx
DeclContext *CD -> DeclContext *DC

It makes the code more consistent."

Patch by Zhongxing Xu!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50105 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-22 18:39:57 +00:00
Douglas Gregor f009795057 Clean up handling of function redeclarations
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50021 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-21 02:02:58 +00:00
Nate Begeman 213541a68a OCUVector -> ExtVector, shorthand for extended vector, per feedback from Chris.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49942 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18 23:10:10 +00:00
Nuno Lopes 59b6d5ae1c fix __attribute__(format) for struct function pointer fields
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49938 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-18 22:43:39 +00:00
Argyrios Kyrtzidis ff898cd0b0 Use TranslationUnitDecl as DeclContext of builtin functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49856 91177308-0d34-0410-b5e6-96231b3b80d8
2008-04-17 14:47:13 +00:00