Commit Graph

23318 Commits

Author SHA1 Message Date
Richard Smith 8d06f42448 Improve 0-argument -Wvexing-parse diagnostic by adding notes with fix-its:
- If the declarator is at the start of a line, and the previous line contained
   another declarator and ended with a comma, then that comma was probably a
   typo for a semicolon:

   int n = 0, m = 1, l = 2, // k = 5;
   myImportantFunctionCall(); // oops!

 - If removing the parentheses would correctly initialize the object, then
   produce a note suggesting that fix.

 - Otherwise, if there is a simple initializer we can suggest which performs
   value-initialization, then provide a note suggesting a correction to that
   initializer.

Sema::Declarator now tracks the location of the comma prior to the declarator in
the declaration, if there is one, to facilitate providing the note. The code to
determine an appropriate initializer from the -Wuninitialized warning has been
factored out to allow use in both that and -Wvexing-parse.

llvm-svn: 148072
2012-01-12 23:53:29 +00:00
Eli Friedman 2e108376d5 Recommit r148056 with fixes to deal with weirdness with bitfields in unions.
Original message: Make sure adding a field to a struct never reduces its size.  PR11745.

llvm-svn: 148070
2012-01-12 23:48:56 +00:00
Eli Friedman 43f1834fad Revert r148056 while I investigate failures.
llvm-svn: 148068
2012-01-12 23:27:03 +00:00
Eli Friedman 8c89d125ff Make sure adding a field to a struct never reduces its size. PR11745.
llvm-svn: 148056
2012-01-12 22:41:25 +00:00
Ted Kremenek 52acee87f4 Adjust set of default checkers.
llvm-svn: 148055
2012-01-12 22:41:10 +00:00
Argyrios Kyrtzidis 0037e08811 If an ObjCMessageExpr is implicit, there are no source locations for the
selector identifiers.

It was difficult to form a test case for it unfortunately.

llvm-svn: 148053
2012-01-12 22:34:19 +00:00
Kaelyn Uhrain fb96ec76ff Convert SemaCXXScopeSpec.cpp to pass a callback object to CorrectTypo,
improvng the typo correction results in certain situations.

llvm-svn: 148052
2012-01-12 22:32:39 +00:00
Fariborz Jahanian e74d47ed03 objc: do not warn when converting to a const id qualfied by its
list of protools. // rdar://10669694

llvm-svn: 148051
2012-01-12 22:12:08 +00:00
Kaelyn Uhrain b02c5e9356 Convert SemaInit.cpp to pass a callback object to CorrectTypo.
And once again improve the typo correction results in certain
situations just by moving the existing checks on the correction.

llvm-svn: 148037
2012-01-12 19:27:05 +00:00
Ted Kremenek 3d3aea9374 [analyzer] fix inlining's handling of mapping actual to formal arguments and limit the call stack depth. The analyzer can now accurately simulate factorial for limited depths.
llvm-svn: 148036
2012-01-12 19:25:46 +00:00
Richard Smith 9eae723c18 constexpr: initialization of a union from an empty initializer-list should
zero-initialize the first union member. Also fix a bug where initializing an
array of types compatible with wchar_t from a wide string literal failed in C,
and fortify the C++ tests in this area. This part can't be tested without a code
change to enable array evaluation in C (where an existing test fails).

llvm-svn: 148035
2012-01-12 18:54:33 +00:00
Hans Wennborg 6073e31baa scanf: parse the 'm' length modifier, and check that the right arguments
are used with that and the 'a' length modifier.

llvm-svn: 148029
2012-01-12 17:11:12 +00:00
Douglas Gregor bf3a826f2c In Objective-C++, actually compute the base type of a member access
expression for an Objective-C object or pointer type, so that we don't
attempt to treat the member name as a template. Fixes
<rdar://problem/10672501>.

llvm-svn: 148028
2012-01-12 16:11:24 +00:00
Hans Wennborg fd950878fa scanf analysis: the 'a' length modifier is valid with a scanlist
Before r148025 we (accidentally) didn't check whether a length modifier is
appropriate for a scanlist, but now we do.

llvm-svn: 148026
2012-01-12 15:07:16 +00:00
Hans Wennborg 32f115f9c1 scanf analysis: don't bail out after successful parse of scanlist
llvm-svn: 148025
2012-01-12 14:44:54 +00:00
Richard Smith 02ab9c2940 Allow constant-folding of references which were formed in a manner not permitted
in a constant expression, for compatibility with g++.

llvm-svn: 148020
2012-01-12 06:08:57 +00:00
Argyrios Kyrtzidis a80f1bf262 Add IsImplicit field in ObjCMessageExpr that is true when the message
was constructed, e.g. for a property access.

This allows the selector identifier locations machinery for ObjCMessageExpr
to function correctly, in that there are not real locations to handle/report for
such a message.

llvm-svn: 148013
2012-01-12 02:34:39 +00:00
Anna Zaks 95f332112f [analyzer] Rename Store::Retrieve() -> getBinding().
+ all the other Retrieve..() methods + a comment for ElementRegion.

llvm-svn: 148011
2012-01-12 02:22:40 +00:00
Anna Zaks b3fa8d7dd1 [analyzer] Add taint transfer by strcpy & others (part 1).
To simplify the process:
Refactor taint generation checker to simplify passing the
information on which arguments need to be tainted from pre to post
visit.

Todo: We need to factor out the code that sema is using to identify the
string and memcpy functions and use it here and in the CString checker.

llvm-svn: 148010
2012-01-12 02:22:34 +00:00
Eric Christopher 8c363622d3 Formatting.
llvm-svn: 147989
2012-01-12 01:26:58 +00:00
Eric Christopher ffbc4d0b68 Formatting.
llvm-svn: 147988
2012-01-12 01:26:51 +00:00
Akira Hatanaka 32604a9708 Take into account the pointer to an aggregate that is passed as a hidden
argument when Offset is initialized.

llvm-svn: 147986
2012-01-12 01:10:09 +00:00
Akira Hatanaka 02e13e5005 Call CodeGenTypes::ConvertType to get LLVM::Type*.
Remove function MipsABIInfo::GetFloatingPointTy.

llvm-svn: 147985
2012-01-12 00:52:17 +00:00
Eli Friedman 42b199c699 Fix some edge cases with C++ casts and placeholder expressions.
llvm-svn: 147984
2012-01-12 00:44:34 +00:00
Fariborz Jahanian 4f8cb1e83a objective-c: fixes a regression in looking up names
in class extensions and categories by recent refactoring
of objc class ASTs. // rdar://1066654

llvm-svn: 147982
2012-01-12 00:18:35 +00:00
Douglas Gregor aab36986ab Improve the diagnostic when trying to redefine a typedef with a
variably-modified type.

llvm-svn: 147973
2012-01-11 22:33:48 +00:00
Kaelyn Uhrain 8811b3904c Fix the caching in CorrectTypo so that other non-keyword identifiers
are still added if the cached correction fails validation.

Also fix a copy-and-paste error in a comment from my previous commit.
Finally, add an example of the benefit the typo correction callback adds
to TryNamespaceTypoCorrection--which happens to also tickle the above
caching problem, as the only way a non-namespace Decl would be added to
the possible corrections is if it was cached as the correction for a
previous instance of the same typo where the typo was corrected to a
non-namespace via a different code path.

llvm-svn: 147968
2012-01-11 21:17:51 +00:00
Fariborz Jahanian a230dea394 minor refactoring to improve compile-time performance.
llvm-svn: 147963
2012-01-11 19:48:08 +00:00
Kaelyn Uhrain 2d317edcfd Add initial callback object support to Sema::CorrectTypo.
Also includes two examples of the callback: a wrapper/replacement for
the CorrectTypoContext enum, and a conversion of the two calls to
CorrectTypo in SemaDeclCXX.cpp (one of which provides verifiable
improvement to the typo correction, as demonstrated in the added test).

llvm-svn: 147962
2012-01-11 19:37:46 +00:00
Fariborz Jahanian 39ba639f9d objc-arc: evaluate 'readonly' property with no known
life-time to that of its backing 'ivar's lifetime.
// rdar://10558871

llvm-svn: 147956
2012-01-11 18:26:06 +00:00
Richard Smith c101e61d31 constexpr: fix typo resulting in move constructors sometimes not being
implicitly marked constexpr when they should be.

llvm-svn: 147955
2012-01-11 18:26:05 +00:00
Evgeniy Stepanov 48af2a9e66 Fix -mfpu parsing on ARM.
- Support gcc-compatible vfpv3 name in addition to vfp3.
- Support vfpv3-d16.
- Disable neon feature for -mfpu=vfp* (yes, we were emitting Neon instructions
  for those!).

llvm-svn: 147943
2012-01-11 11:21:31 +00:00
Abramo Bagnara fa95ed4074 Fixed VLA code generation.
llvm-svn: 147933
2012-01-11 08:19:46 +00:00
Ted Kremenek 940e00f299 "This change adds alloca/valloc checks to UnixAPIChecker. It includes a small refactoring for
the common *alloc functions as well as a few tiny wibbles (adds a note
to CWE/CERT advisory numbers in the bug output, and fixes a couple
80-column-wide violations.)"

Patch by Austin Seipp!

llvm-svn: 147931
2012-01-11 08:13:21 +00:00
Douglas Gregor 7363fb05fd C11 allows typedefs to be redefined. Implement this in C11 mode, and
downgrade the default-error warning to an ExtWarn in
C90/99. <rdar://problem/10668057>

llvm-svn: 147925
2012-01-11 04:25:01 +00:00
Eli Friedman 027e9c3ebc Revert changes to lib/Driver in r147917; I didn't mean to commit this.
llvm-svn: 147920
2012-01-11 02:41:15 +00:00
Zhongxing Xu f0cb43f561 Add elidable CXXConstructExpr as block-level expr. It converts an lvalue to a rvalue, which is a useful step during AST evaluation.
llvm-svn: 147918
2012-01-11 02:39:07 +00:00
Eli Friedman 20139d3809 Start refactoring code for capturing variables and 'this' so that it is shared between lambda expressions and block literals.
llvm-svn: 147917
2012-01-11 02:36:31 +00:00
Ted Kremenek 3f406ba4bf Remove '#if 0' from ExprEngine::InlineCall(), and start fresh by wiring up inlining for straight C calls.
My hope is to reimplement this from first principles based on the simplifications of removing unneeded node builders
and re-evaluating how C++ calls are handled in the CFG.  The hope is to turn inlining "on-by-default" as soon as possible
with a core set of things working well, and then expand over time.

llvm-svn: 147904
2012-01-11 01:06:27 +00:00
John McCall 9b80c2186f Do placeholder conversions on array bounds in both declarators and
new-expressions.

llvm-svn: 147900
2012-01-11 00:14:46 +00:00
Akira Hatanaka ee65b744e8 Remove switch/case statements and call GetFloatingPointTy() instead to get the
floating point type.

llvm-svn: 147894
2012-01-10 23:30:49 +00:00
Akira Hatanaka 79f0461c38 Flatten float complex arguments. N32/64 requires float complex arguments be
passed in floating point registers.

llvm-svn: 147892
2012-01-10 23:12:19 +00:00
Akira Hatanaka 21ee88cc1c Remove space.
llvm-svn: 147889
2012-01-10 22:44:52 +00:00
Akira Hatanaka 428f5b2008 Add field IsIEEE in FloatingLiteral to distinguish between different 128-bit
floating point formats.

llvm-svn: 147887
2012-01-10 22:40:09 +00:00
Douglas Gregor 21b3b298c4 When something goes wrong in type-checking a namespace definition, make the namespace declaration invalid
llvm-svn: 147882
2012-01-10 22:14:10 +00:00
Chandler Carruth c89aa9d964 Add support for the androideabi environment to our triple support, and
for the arm-linux-androideabi triple in particular.

Also use this to do a better job of selecting soft FP settings.

Patch by Evgeniy Stepanov.

llvm-svn: 147872
2012-01-10 19:47:42 +00:00
Fariborz Jahanian edbc345170 objc-arc: fixes a crash when trying to find out retaining cycle
ownership of property sent to 'super'. // rdar://10640891

llvm-svn: 147868
2012-01-10 19:28:26 +00:00
Chandler Carruth bfe8ecd347 Remove a set, but unused variable. Found with GCC's warning.
llvm-svn: 147864
2012-01-10 18:26:14 +00:00
Joerg Sonnenberger 11aaa7102a Contrary to the other BSDs, NetBSD followed the ELF ABI for structure
passing on i386 and does not use registers.

llvm-svn: 147856
2012-01-10 16:53:17 +00:00
Ted Kremenek c07e34ceed Make PathDiagnosticLocation more resilient to null Stmt pointers.
llvm-svn: 147854
2012-01-10 15:26:13 +00:00
Benjamin Kramer 569f215771 Add definitions for AMD's bobcat (aka btver1)
llvm-svn: 147849
2012-01-10 11:50:18 +00:00
Benjamin Kramer edbc59a27e Enable POPCNT and LZCNT with sse4a.
llvm-svn: 147848
2012-01-10 11:50:13 +00:00
Benjamin Kramer e3b442d20c Factor the repetitive cpu macro definition into a helper function.
llvm-svn: 147847
2012-01-10 11:50:09 +00:00
Bill Wendling 86131f2c8d The `-fwritable-strings' flag doesn't make the backing store strings of all
CFStrings writable.

The strings (both Unicode and ASCII) should reside in a read-only section. E.g.,
__TEXT,__cstring instead of __DATA,__data. This is done by making the global
variable created for the strings constant despite the value of that flag.
<rdar://problem/10657500>

llvm-svn: 147845
2012-01-10 08:46:39 +00:00
Eli Friedman c4b251dc2b Implement the missing pieces of Evaluate for _Complex types. With that complete, remove some code from CGExprConstant which is no longer necessary. While I'm here, a couple minor tweaks to _Complex-in-C++. (Specifically, make _Complex types literal types, and don't warn for _Complex int.)
llvm-svn: 147840
2012-01-10 04:58:17 +00:00
Richard Smith 1bc5c2c7ef PR11724: Implement evaluation for constexpr defaulted trivial union copy/move
constructors. These are a special case whose behavior cannot be modeled as a
user-written constructor.

llvm-svn: 147839
2012-01-10 04:32:03 +00:00
Eli Friedman 9163e360d6 Per John's comment, it makes sense to ask isLambda on any CXXRecordDecl; make sure that's safe. Get rid of a check which is now unnecessary in Sema::getFunctionLevelDeclContext().
llvm-svn: 147837
2012-01-10 03:38:46 +00:00
Richard Smith 0f8ee22655 Update C++11 scoped enumeration support to match the final proposal:
- reject definitions of enums within friend declarations
 - require 'enum', not 'enum class', for non-declaring references to scoped
   enumerations

llvm-svn: 147824
2012-01-10 01:33:14 +00:00
Eric Christopher fc3ee566eb Add -g to the cc1as flags only if we're dealing with an original
source file. Otherwise -g -save-temps will error out on the compile
of any .c file.

Fixes about 4000 of the errors in the clang-tests gdb test suite.

llvm-svn: 147819
2012-01-10 00:38:01 +00:00
Eric Christopher fe2603a78a Remove extraneous braces.
llvm-svn: 147818
2012-01-10 00:37:56 +00:00
Fariborz Jahanian a08a74705b objc++: patch for IRgen for atomic properties of
c++ objects with non-trivial assignment/copy functions.
Also, one additional sema check. // rdar://6137845

llvm-svn: 147817
2012-01-10 00:37:01 +00:00
Eli Friedman 7f21bd74b8 Don't crash with -Wlarge-by-value-copy and a dependent type. PR11726.
llvm-svn: 147812
2012-01-09 23:46:59 +00:00
Richard Smith c8a79033ba Extend the diagnostic for a ',' at the end of a declaration where a ';' was
intended to cover C++ class definitions.

llvm-svn: 147808
2012-01-09 22:31:44 +00:00
Nico Weber a8f80b31f9 Fix "note" of a duplicate explicit instantiation definition following a specialization.
llvm-svn: 147798
2012-01-09 19:52:25 +00:00
Akira Hatanaka 1632af603d Insert padding before unaligned long double arguments.
llvm-svn: 147791
2012-01-09 19:31:25 +00:00
Akira Hatanaka 18334dd9e9 Move the piece of code up that skips the padding argument. Without this change,
padding insertion will not work if the coerced type is not a structure.

llvm-svn: 147786
2012-01-09 19:08:06 +00:00
Douglas Gregor 540fd8135e When deserializing an anonymous namespace from a module, do not attach
the anonymous namespace to its parent. Semantically, this means that
the anonymous namespaces defined in one module are distinct from the
anonymous namespaces defined in another module.

llvm-svn: 147782
2012-01-09 18:07:24 +00:00
Douglas Gregor 9b47f94133 Implement merging of namespace-scope declarations across modules, so
that we can merge, for example, two occurrences of

  namespace N { void f(); }

in two disjoint modules.

llvm-svn: 147780
2012-01-09 17:38:47 +00:00
Douglas Gregor cfe7dc6b2f Implement redeclaration merging for namespaces defined in distinct
modules. Teach name lookup into namespaces to search in each of the
merged DeclContexts as well as the (now-primary) DeclContext. This
supports the common case where two different modules put something
into the same namespace.

llvm-svn: 147778
2012-01-09 17:30:44 +00:00
Douglas Gregor dbd93bfc2d Always allow redefinition of typedefs when modules are enabled. This
is important because it's fairly common for headers (especially system
headers) to want to provide only those typedefs needed for that
particular header, based on some guard macro, e.g.,

#ifndef _SIZE_T
#define _SIZE_T
typedef long size_t;
#endif

which is repeated in a number of headers. The guard macro protects
against duplicate definitions. However, this means that only the first
occurrence of this pattern actually defines size_t, so the submodule
corresponding to this header has the only visible definition. If a
user then imports a different submodule from the same module, size_t
will be known but not visible, and therefore cannot be used.

By allowing redefinition of typedefs, each header that wants to define
size_t can do so independently, so it will be available in the
corresponding submodules.

llvm-svn: 147775
2012-01-09 15:36:04 +00:00
Abramo Bagnara 3732fa5417 Made unknown builtin diagnostic remappable.
llvm-svn: 147774
2012-01-09 10:05:48 +00:00
Craig Topper 23b9219765 Merge AVX/AVX2 into the SSE level.
llvm-svn: 147771
2012-01-09 09:19:09 +00:00
Fariborz Jahanian 1bed413c89 objc++: more atomic property api code for
c++ object properties. wip.

llvm-svn: 147750
2012-01-08 19:13:23 +00:00
Rafael Espindola 47dbcd1d39 Remove unused variable.
llvm-svn: 147744
2012-01-07 22:52:07 +00:00
Benjamin Kramer e78f8ee57f Pack UsingDecl more.
88 -> 80 bytes on x86_64.

llvm-svn: 147736
2012-01-07 19:09:05 +00:00
Fariborz Jahanian 4b501a2ed8 objc++: More codegen stuff for atomic properties of c++ objects
with non-trivial copies. // rdar://6137845

llvm-svn: 147735
2012-01-07 18:56:22 +00:00
Anna Zaks 17f57b0a00 [analyzer] Fix use-after-free in HandleTranslationUnit.
A patch by Dmitri Gribenko!

The attached patch fixes a use-after-free in AnalysisConsumer::HandleTranslationUnit.  The problem is that
BugReporter's destructor runs after AnalysisManager has been already
deleted.  The fix introduces a scope to force correct destruction
order.

A crash happens only when reports have been added in AnalysisConsumer::HandleTranslationUnit's BugReporter. We don't have such checkers in clang so no test.

llvm-svn: 147732
2012-01-07 16:49:46 +00:00
Abramo Bagnara 1cd8368eb2 Fixed TypeofExpr AST and code generation.
llvm-svn: 147730
2012-01-07 10:52:36 +00:00
Douglas Gregor e57e752b71 Switch NamespaceDecl from its own hand-rolled redeclaration chain over
to Redeclarable<NamespaceDecl>, so that we benefit from the improveed
redeclaration deserialization and merging logic provided by
Redeclarable<T>. Otherwise, no functionality change.

As a drive-by fix, collapse the "inline" bit into the low bit of the
original namespace/anonymous namespace, saving 8 bytes per
NamespaceDecl on x86_64.

llvm-svn: 147729
2012-01-07 09:11:48 +00:00
Eli Friedman 73a040906d More lambda work: semantic analysis of capturing 'this'. It's a bit complicated, but we have to be careful about when exactly captures are marked given PotentiallyPotentiallyEvaluated contexts. (Actually, it's not 100% correct yet, but it's close enough for the moment.)
llvm-svn: 147723
2012-01-07 04:59:52 +00:00
Anna Zaks 126a2ef920 [analyzer] Add basic format string vulnerability checking.
We already have a more conservative check in the compiler (if the
format string is not a literal, we warn). Still adding it here for
completeness and since this check is stronger - only triggered if the
format string is tainted.

llvm-svn: 147714
2012-01-07 02:33:10 +00:00
Eli Friedman 44803326d4 Lambdas: semantic analysis of explicit captures.
This patch (and some of my other commits related to lambdas) is heavily based off of John Freeman's work-in-progress patches.

llvm-svn: 147706
2012-01-07 01:08:17 +00:00
Ted Kremenek e1181f3ea0 [analyzer] Remove CallEnterNodeBuilder and simplify ExprEngine::processCallEnter().
This removes analysis of other translation units, but that was an experimental feature anyway that we will revisit later.

llvm-svn: 147705
2012-01-07 01:03:17 +00:00
Akira Hatanaka f64e1adcbb Add field PaddingType to ABIArgInfo which specifies the type of padding that
is inserted before the real argument. Padding is needed to ensure the backend
reads from or writes to the correct argument slots when the original alignment
of a byval structure is unavailable due to flattening.

llvm-svn: 147699
2012-01-07 00:25:33 +00:00
Ted Kremenek 6cb36f7a30 Correctly enqueue successors in ExprEngine::processCallExit().
llvm-svn: 147698
2012-01-07 00:10:49 +00:00
Ted Kremenek aee86cee35 [analyzer] Remove CallExitNodeBuilder, and have ExprEngine::processCallExit() do the work manually. This is a nice simplification.
Along the way, fix Exprengine::processCallExit() to also perform the postStmt callback for checkers for CallExprs.

llvm-svn: 147697
2012-01-07 00:00:59 +00:00
Matt Beaumont-Gay 7a57adab83 Suppress -Wunused-value within macros from system headers.
Along the way, move a helper function from SemaChecking.cpp to a more
accessible home in SourceManager.

llvm-svn: 147692
2012-01-06 22:43:58 +00:00
Fariborz Jahanian 7ff610b62d objc++: more code gen stuff for atomic property api,
currently turned off. // rdar://6137845
Also, fixes a test case which should be nonatomic under
new API.

llvm-svn: 147691
2012-01-06 22:33:54 +00:00
Ted Kremenek 632e3b7ee2 [analyzer] Make the entries in 'Environment' context-sensitive by making entries map from
(Stmt*,LocationContext*) pairs to SVals instead of Stmt* to SVals.

This is needed to support basic IPA via inlining.  Without this, we cannot tell
if a Stmt* binding is part of the current analysis scope (StackFrameContext) or
part of a parent context.

This change introduces an uglification of the use of getSVal(), and thus takes
two steps forward and one step back.  There are also potential performance implications
of enlarging the Environment.  Both can be addressed going forward by refactoring the
APIs and optimizing the internal representation of Environment.  This patch
mainly introduces the functionality upon when we want to build upon (and clean up).

llvm-svn: 147688
2012-01-06 22:09:28 +00:00
Douglas Gregor 5407920f82 During name lookup, use redecl_iterator to walk over the redeclaration
chain to determine whether any declaration of the given entity is
visible, eliminating the redundant (and less efficient)
getPreviousDeclaration() implementation.

This tweak uncovered an omission in the handling of
RedeclarableTemplateDecl, where we weren't making sure to search for
additional redeclarations of a template in other module files. Things
would be cleaner if RedeclarableTemplateDecl actually used Redeclarable.

llvm-svn: 147687
2012-01-06 22:05:37 +00:00
Eli Friedman 48fd89ad14 Revert r147664; it's breaking clang regression tests.
llvm-svn: 147681
2012-01-06 20:42:20 +00:00
Chad Rosier 598f3d219d Fix uninitialized variable warning.
llvm-svn: 147678
2012-01-06 20:05:14 +00:00
Eli Friedman df88c54f8d Revert r147655; it's breaking the compiler_rt build on OSX.
llvm-svn: 147677
2012-01-06 20:03:09 +00:00
DeLesley Hutchins 9d53033de6 Thread safety analysis: added support for trylock attribute.
llvm-svn: 147672
2012-01-06 19:16:50 +00:00
DeLesley Hutchins 9b7022e570 Added LocalVariableMap
llvm-svn: 147670
2012-01-06 18:36:09 +00:00
Joerg Sonnenberger 1623714010 __FLT_EVAL_METHOD__ should be 1 on NetBSD/i386, since it defaults to
"double" rounding.

llvm-svn: 147669
2012-01-06 18:32:26 +00:00
Fariborz Jahanian 1e1b54926b objc++: some declarations related to atomic
properties of c++ object types with non-trivial
assignment copy. Not used yet. // rdar://6137845

llvm-svn: 147666
2012-01-06 18:07:23 +00:00
Jakub Staszak a78c20d734 Silence GCC warnings.
llvm-svn: 147664
2012-01-06 17:44:30 +00:00
Douglas Gregor 224d8a74ae When inferring a submodule ID during module creation, look up the
include stack to find the first file that is known to be part of the
module. This copes with situations where the module map doesn't
completely specify all of the headers that are involved in the module,
which can come up when there are very strange #include_next chains
(e.g., with weird compiler/stdlib headers like stdarg.h or float.h).

llvm-svn: 147662
2012-01-06 17:19:32 +00:00
Douglas Gregor 781f713deb Stash Decl's TopLevelDeclInObjCContainer and ModulePrivate bits
into the two unused lower bits of the NextDeclInContext link, dropping
the number of bits in Decl down to 32, and saving 8 bytes per
declaration on x86-64.

llvm-svn: 147660
2012-01-06 16:59:53 +00:00
Richard Smith a8105bc9ce C++11 generalized constant expressions: implement checking and diagnostics for
pointer-arithmetic-related undefined behavior and unspecified results. We
continue to fold such values, but now notice they aren't constant expressions.

llvm-svn: 147659
2012-01-06 16:39:00 +00:00
Douglas Gregor 768e5b1e9a Introduce a "Hidden" bit into Decl, to track whether that declaration
is hidden from name lookup. The previous hack of tweaking the
ModulePrivate bit when loading a declaration from a hidden submodule
was brittle.

Note that we now have 34 bits in Decl. I'll fix that next.

llvm-svn: 147658
2012-01-06 16:22:39 +00:00
Douglas Gregor de95ead949 Teach DeclContext deserialization to pay attention to endianness, from
David Fang and Takumi Nakamura. Fixes many PCH failures on PowerPC.

llvm-svn: 147657
2012-01-06 16:09:53 +00:00
David Chisnall 9217435a33 If we are compiling with -fno-builtin then don't do constant folding of
builtins.

This fixes PR11711.

llvm-svn: 147655
2012-01-06 12:20:19 +00:00
John McCall 8ba2f20bc0 Fix the mangling of class template arguments in a particular
dependent case.  Thanks to Jason Merrill for pointing this out.

llvm-svn: 147653
2012-01-06 05:06:35 +00:00
Rafael Espindola 7c23b0891b Improvements to the uninitialized variable warning: Check if the constructor
call is elidable or if the constructor is trivial instead of checking if it
is user declared.

llvm-svn: 147652
2012-01-06 04:54:01 +00:00
Eli Friedman 4817cf72f6 More lambda work. Fixes a minor bug Richard pointed out, makes lookup for lambda parameters work correctly, recording more information into the AST.
llvm-svn: 147650
2012-01-06 03:05:34 +00:00
Richard Smith b3851f5ca1 David Blaikie and Chandler would like us to diagnose
int f();

in function scopes under -Wvexing-parse, so now we do.

llvm-svn: 147649
2012-01-06 02:30:50 +00:00
Richard Smith d069d2f6ac Tweak to r147599 for PR10828: Move the check from the parser into sema, and use
the Semantic Powers to only warn on class types (or dependent types), where the
constructor or destructor could do something interesting.

llvm-svn: 147642
2012-01-06 01:31:20 +00:00
Eli Friedman 5c5e3b7e84 Minor refactoring of sentinel warning on blocks. Add a test for this warning.
llvm-svn: 147641
2012-01-06 01:23:10 +00:00
Fariborz Jahanian 17eaf4089d objc++: sythesize a helper function to be used
for copying atomic properties of c++ objects
with non-trivial copy assignment in setters/getters.
Not yet used. // rdar://6137845

llvm-svn: 147636
2012-01-06 00:29:35 +00:00
Argyrios Kyrtzidis 7ce752610f Fix a memory leak of PragmaNamespaces, rdar://10611796.
llvm-svn: 147635
2012-01-06 00:22:09 +00:00
Eli Friedman b1bc368ca7 Address Richard's review comments on r147561 (Evaluate support for address-of-label differences).
llvm-svn: 147631
2012-01-05 23:59:40 +00:00
Douglas Gregor 52261fd2f7 Always allocate an extra 8 bytes for a deserialized declaration, since
some code in Clang expects 8-byte alignment of declarations.

llvm-svn: 147626
2012-01-05 23:49:36 +00:00
Ted Kremenek 0c2c90b1ad After further discussion, rename attribute 'objc_disable_automatic_synthesis' to 'objc_requires_property_definitions'.
llvm-svn: 147622
2012-01-05 22:47:47 +00:00
Eli Friedman de30e523b4 Tweak the fix to PR8977: an empty expression-list represents value initialization, not default initialization. Fixes PR11712.
llvm-svn: 147620
2012-01-05 22:34:08 +00:00
Douglas Gregor b3163e574e Don't seed the ASTWriter's declaration -> ID mapping with the IDs of
each deserialized declaration, since that information is already
available in each declaration.

llvm-svn: 147619
2012-01-05 22:33:30 +00:00
Douglas Gregor 64af53c364 When we deserialize a declaration from a module file, allocate extra
storage for the global declaration ID. Declarations that are parsed
(rather than deserialized) are unaffected, so the number of
declarations that pay this cost tends to be relatively small (since
relatively few declarations are ever deserialized).

This replaces a largish DenseMap within the AST reader. It's not
strictly a win in terms of memory use---not every declaration was
added to that DenseMap in the first place---but it's cleaner to have
this information available for every deserialized declaration, so that
future clients can rely on it.

llvm-svn: 147617
2012-01-05 22:27:05 +00:00
Douglas Gregor 72172e9009 When creating declarations that are deserialized from an module file,
go through a central allocation routine
Decl::AllocateDeserializedDecl(). No actual functionality change (yet).

llvm-svn: 147614
2012-01-05 21:55:30 +00:00
Argyrios Kyrtzidis 9afd449e8f When loading an AST file, set SourceManager::MainFileID to the main file of the AST file,
as suggested by Tom Honermann.

llvm-svn: 147612
2012-01-05 21:36:25 +00:00
Richard Smith 69f90dce49 PR10828: Produce a warning when a no-arguments function is declared in block
scope, when no other indication is provided that the user intended to declare a
function rather than a variable.

Remove some false positives from the existing 'parentheses disambiguated as a
function' warning by suppressing it when the declaration is marked as 'typedef'
or 'extern'.

Add a new warning group -Wvexing-parse containing both of these warnings.

The new warning is enabled by default; despite a number of false positives (and
one bug) in clang's test-suite, I have only found genuine bugs with it when
running it over a significant quantity of real C++ code.

llvm-svn: 147599
2012-01-05 04:12:21 +00:00
Eli Friedman 71c8055f8e More lambda work. Tweak the Sema interface slightly. Start adding the pieces to build the lambda class and its call operator. Create an actual scope for the lambda body.
llvm-svn: 147595
2012-01-05 03:35:19 +00:00
Douglas Gregor 5c193c7ed6 When we're performing name lookup for a tag, we still allow ourselves
to see hidden declarations because every tag lookup is effectively a
redeclaration lookup. For example, image that

  struct foo;

is declared in a submodule that is known but hasn't been imported. If
someone later writes

  struct foo *foo_p;

then "struct foo" is either a reference or a redeclaration. To keep
the redeclaration chains sound, we treat it like a redeclaration for
name-lookup purposes.

llvm-svn: 147588
2012-01-05 01:11:47 +00:00
Eli Friedman de958784d6 Minor cleanup; no functional change.
llvm-svn: 147582
2012-01-05 00:49:17 +00:00
John McCall a59dc2f8f0 The value of a const weak variable is not an integer constant.
llvm-svn: 147575
2012-01-05 00:13:19 +00:00
Douglas Gregor fcc54a3b91 If we already have a definition for a top-level module that we deserialized from a module file, don't bother parsing a new definition
llvm-svn: 147574
2012-01-05 00:12:00 +00:00
Fariborz Jahanian 088f1bc295 Fixes a code gen bug for setter code for a property of
c++ object reference type with trivial copy constructor.
This causes an assert crash and bad code gen. when assert 
is off. // rdar://6137845

llvm-svn: 147573
2012-01-05 00:10:16 +00:00
Douglas Gregor d2a8fe187d When generating includes for all of the headers we found in an
umbrella directory, skip includes for any headers that are part of an
unavailable module.

llvm-svn: 147572
2012-01-05 00:04:05 +00:00
Anna Zaks 8158ef0dec [analyzer] Be less pessimistic about invalidation of global variables
as a result of a call.

Problem:
Global variables, which come in from system libraries should not be
invalidated by all calls. Also, non-system globals should not be
invalidated by system calls.

Solution:
The following solution to invalidation of globals seems flexible enough
for taint (does not invalidate stdin) and should not lead to too
many false positives. We split globals into 3 classes:

* immutable - values are preserved by calls (unless the specific
global is passed in as a parameter):
     A :  Most system globals and const scalars

* invalidated by functions defined in system headers:
     B: errno

* invalidated by all other functions (note, these functions may in
turn contain system calls):
     B: errno
     C: all other globals (which are not in A nor B)

llvm-svn: 147569
2012-01-04 23:54:01 +00:00
Ted Kremenek dec9d12fc4 Rename attribute 'objc_suppress_autosynthesis' to 'objc_disable_automatic_synthesis'.
llvm-svn: 147567
2012-01-04 23:51:09 +00:00
Ted Kremenek 778d2bb8d4 Fix 80 col violations.
llvm-svn: 147566
2012-01-04 23:48:37 +00:00
Douglas Gregor eb90e83085 Store the submodules of a module in source order, as they are stored
in the module map. This provides a bit more predictability for the
user, as well as eliminating the need to sort the submodules when
serializing them.

llvm-svn: 147564
2012-01-04 23:32:19 +00:00
Fariborz Jahanian 783ffde6d3 objc: When issuing warning for missing synthesis for
properties in classes declared with objc_suppress_autosynthesis
attribute, pinpoint location of the said class in a note.

llvm-svn: 147562
2012-01-04 23:16:13 +00:00
Eli Friedman fd5e54da2d Add an APValue representation for the difference between two address-of-label expressions. Add support to Evaluate and CGExprConstant for generating/handling them. Remove the special-case for such differences in Expr::isConstantInitializer.
With that done, remove a bunch of buggy code from CGExprConstant for handling scalar expressions which is no longer necessary.

Fixes PR11705.

llvm-svn: 147561
2012-01-04 23:13:47 +00:00
Chris Lattner 36bc4f41bc implement rdar://10639962 by keeping track of increased alignment
information even in subscripting operations.

llvm-svn: 147557
2012-01-04 22:35:55 +00:00
Daniel Dunbar ecb41cbcd6 Driver/Darwin: Remove a hack that avoided passing -demangle to iOS linkers.
llvm-svn: 147552
2012-01-04 21:45:27 +00:00
Douglas Gregor 7f9abbdcc5 Add __has_feature(modules) to indicate when modules are available (in
any language variant), and restrict __has_feature(objc_modules) to
mean that we also have the Objective-C @import syntax. I anticipate
__has_feature(cxx_modules) and/or __has_feature(c_modules) for when we
nail down the module syntax for C/C++.

llvm-svn: 147548
2012-01-04 21:16:09 +00:00
Douglas Gregor b8c6f1e950 Implement declaration merging for variables in disjoint modules.
llvm-svn: 147535
2012-01-04 17:21:36 +00:00
Douglas Gregor b258569405 Implement declaration merging for non-template functions from
different modules. This implementation is a first approximation of
what we want, using only the function type to determine
equivalence. Later, we'll want to deal with some of the more subtle
issues, including:

  - C allows a prototyped declaration and a non-prototyped declaration
    to be merged, which we should support
  - We may want to ignore the return type when merging, then
    complain if the return types differ. Or, we may want to leave it
    as it us, so that we only complain if overload resolution
    eventually fails.
  - C++ non-static member functions need to consider cv-qualifiers
    and ref-qualifiers.
  - Function templates need to consider the template parameters and
    return type.
  - Function template specializations will have special rules.
  - We can now (accidentally!) end up overloading in C, even without
    the "overloadable" attribute, and will need to detect this at some
    point.
  
The actual detection of "is this an overload?" is implemented by
Sema::IsOverload(), which will need to be moved into the AST library
for re-use here. That will be a future refactor.

llvm-svn: 147534
2012-01-04 17:13:46 +00:00
Douglas Gregor 9b7b39116e Implement declaration merging for typedefs loaded from disjoint
modules, so long as the typedefs refer to the same underlying
type. This ensures that the typedefs end up in the same redeclaration
chain.

To test this, fix name lookup for C/Objective-C to properly deal with
multiple declarations with the same name in the same scope.

llvm-svn: 147533
2012-01-04 16:44:10 +00:00
Benjamin Kramer 6dced3b468 Penryn doesn't support sse4.2, don't enable it in the first place.
While the code took care of disabling the sse42 flag it didn't know
about popcnt. This broke -march=native on penryn.

llvm-svn: 147531
2012-01-04 14:36:57 +00:00
David Chisnall 207a630052 Restore r147493 and remove the part of the test that was checking the wrong thing.
llvm-svn: 147530
2012-01-04 12:02:13 +00:00
Ted Kremenek 5799cddde0 Extend ConditionBRVisitor to handle condition variable assignments.
llvm-svn: 147526
2012-01-04 08:18:09 +00:00
Douglas Gregor 8d76cca3a2 Don't treat 'import' as a contextual keyword when we're in a caching lexer, or when modules are disabled.
llvm-svn: 147524
2012-01-04 06:20:15 +00:00
Rafael Espindola 2aa7acfadb Process attributes in explicit function template instantiations. Fixes part of
PR11690.

llvm-svn: 147523
2012-01-04 05:40:59 +00:00
Eli Friedman 36d129435e Add an explicit LambdaExprContext to Declarator, to parallel BlockLiteralContext. Use it to ensure semantic analysis of types isn't confused by the lack of a type specifier.
llvm-svn: 147522
2012-01-04 04:41:38 +00:00
Akira Hatanaka f093f5be3e Have functions return structures smaller than 128-bit in registers if ABI
is either N32 or N64. 

llvm-svn: 147520
2012-01-04 03:34:42 +00:00
Eli Friedman 898caf8f26 Fix messed-up indentation in r147515.
llvm-svn: 147517
2012-01-04 02:46:53 +00:00
Eli Friedman c7c97144af Stub out the Sema interface for lambda expressions, and change the parser to use it. Unconditionally error on lambda expressions because they don't work in any meaningful way yet.
llvm-svn: 147515
2012-01-04 02:40:39 +00:00
Rafael Espindola f90b6d1580 Revert r147493. It broke test/CodeGenObjC/constant-strings.m.
llvm-svn: 147511
2012-01-04 01:32:19 +00:00
Ted Kremenek 990464cb30 Teach the static analyzer to not treat XPC types as CF types.
llvm-svn: 147506
2012-01-04 00:35:48 +00:00
Ted Kremenek e8300e5eba Minor code formatting cleanups.
llvm-svn: 147505
2012-01-04 00:35:45 +00:00
Fariborz Jahanian 1fc1c6c307 In non-gc, non-arc mode, property of 'Class' type
variety is treated as a 'void *'. No need to issue
warning reserved for objc object properties.
// rdar://10565506

llvm-svn: 147504
2012-01-04 00:31:53 +00:00
Eli Friedman 90dc17510b Get rid of an unnecessary check; the AST for init-lists is the same independent of whether we're in C++11 mode.
llvm-svn: 147503
2012-01-03 23:54:05 +00:00
Ted Kremenek 134a83a799 Enhance UnixAPIChecker to also warn about zero-sized allocations to calloc() and realloc(). Patch by Cyril Roelandt!
llvm-svn: 147500
2012-01-03 23:43:13 +00:00
Douglas Gregor 6aeecf1791 Minor tweak to name lookup for C/Objective-C: after the first name, still consider whether this is a redeclaration lookup when determining whether to look for the visible declaration
llvm-svn: 147499
2012-01-03 23:34:23 +00:00
Douglas Gregor b59643baf6 Test "merging" of typedef types across distinct modules. At present,
the AST reader doesn't actually perform a merge, because name lookup
knows how to merge identical typedefs together.

As part of this, teach C/Objective-C name lookup to return multiple
results in all cases, rather than first digging through the attributes
to see if the value is overloadable. This way, we'll catch ambiguous
lookups in C/Objective-C.

llvm-svn: 147498
2012-01-03 23:26:26 +00:00
Eli Friedman b9c7129012 Support constant evaluation for OpenCL nested vector literals. Patch by Anton Lokhmotov.
llvm-svn: 147496
2012-01-03 23:24:20 +00:00
Ted Kremenek b3512d3a48 Add initial version of checker to check if virtual member functions are called transitively
from C++ constructors or destructors.  Checker by Lei Zhang with a few tweaks by Ted Kremenek.

llvm-svn: 147494
2012-01-03 23:18:57 +00:00
David Chisnall 31640e1606 Initialise constant Objective-C string isa pointers with a weak reference to the class, so that they are usable in +load methods if the string class has been compiled with clang - if it's been compiled with GCC, the ABI makes this impossible. (GNU runtimes)
llvm-svn: 147493
2012-01-03 23:18:17 +00:00
Fariborz Jahanian 7249e36704 objc: diagnose misplacement of objc_suppress_autosynthesis
attribute.

llvm-svn: 147490
2012-01-03 22:52:32 +00:00
Chad Rosier 1ad2433690 Fixed by Chandler in r147434.
llvm-svn: 147489
2012-01-03 22:51:32 +00:00
Douglas Gregor 2009ceed82 Implement cross-module declaration merging for tag declarations, so
that if two modules A and B both contain a declaration of a tag such
as

  struct X;

and those two modules are unrelated, the two declarations of X will be
merged into a single redeclaration chain.

llvm-svn: 147488
2012-01-03 22:46:00 +00:00
Douglas Gregor 173d499c25 Add __has_feature(objc_modules)
llvm-svn: 147482
2012-01-03 21:12:26 +00:00
Douglas Gregor 663b48f13b Re-uglify #public and #private to #__public_macro and #__private_macro.
llvm-svn: 147469
2012-01-03 19:48:16 +00:00
Fariborz Jahanian 3c9707bd90 objc: use objc_suppress_autosynthesis attribute on classes
which should not be default synthesized.

llvm-svn: 147468
2012-01-03 19:46:00 +00:00
Douglas Gregor da82e703d1 Eliminate the uglified keyword __import_module__ for importing
modules. This leaves us without an explicit syntax for importing
modules in C/C++, because such a syntax needs to be discussed
first. In Objective-C/Objective-C++, the @import syntax is used to
import modules.

Note that, under -fmodules, C/C++ programs can import modules via the
#include mechanism when a module map is in place for that header. This
allows us to work with modules in C/C++ without committing to a syntax.

llvm-svn: 147467
2012-01-03 19:32:59 +00:00
Joerg Sonnenberger c2f91c37e8 Don't depend on undefined macros being 0, there are options for the
preprocessor to warn about it.

llvm-svn: 147466
2012-01-03 19:22:38 +00:00
Fariborz Jahanian 9d4d20af55 objc: introduce objc_suppress_autosynthesis class
attributes for later use.

llvm-svn: 147457
2012-01-03 18:45:41 +00:00
Douglas Gregor 0bf886d41a Under -fmodules, accept #public <macroname> and #private <macroname>
to make a macro public (the default for headers) or private,
respectively.

llvm-svn: 147455
2012-01-03 18:24:14 +00:00
Douglas Gregor 22d0974b40 Introduce a non-uglified syntax for module imports in Objective-C:
@import identifier [. identifier]* ;

llvm-svn: 147452
2012-01-03 18:04:46 +00:00
Douglas Gregor e097d4ba26 Don't attempt to merge a deserialized declaration with existing
declarations in the AST unless modules are enabled. This case doesn't
come up with precompiled headers, and it isn't cheap.

llvm-svn: 147451
2012-01-03 17:31:38 +00:00
Douglas Gregor 2c46b5bd07 Factor the merging of declarations in the AST reader out to a separate
member function template, since the behavior is identical for
ObjCInterfaceDecl and ObjCProtocolDecl. It's expected that all
redeclarable entities will have the same behavior.

llvm-svn: 147450
2012-01-03 17:27:13 +00:00
Douglas Gregor 787869b929 Add -fno-modules to the driver, to turn off modules (although they're off by default anyway).
llvm-svn: 147449
2012-01-03 17:13:05 +00:00
Douglas Gregor ad01b31b94 Add a "Modules" language option, which subsumes the previous
"AutoModuleImport" preprocessor option and is tied to -fmodules.

llvm-svn: 147448
2012-01-03 17:07:34 +00:00
Douglas Gregor 2f197adeeb Rename the command-line option for mapping #include/#import over to
module imports from -fauto-module-import to -fmodules. The new name
will eventually be used to enable modules, and the #include/#import
mapping is a crucial part of the feature.

llvm-svn: 147447
2012-01-03 15:21:29 +00:00
Rafael Espindola 0b0620776a Process attributes in explicit template instatiation definitions. Fixes PR11690.
llvm-svn: 147441
2012-01-03 06:04:21 +00:00
Chandler Carruth 3a5ff5cbd2 Teach the frontend to provide the builtin preprocessor defines for
-ffast-math.

llvm-svn: 147440
2012-01-03 02:46:46 +00:00
Richard Smith dbfd4037fc Add assertion to char32_t that the value is valid, as suggested by Jordy Rose.
Add a test that such characters don't make it through to StringLiteral objects
in error recovery.

llvm-svn: 147438
2012-01-02 18:14:06 +00:00
Douglas Gregor 5dbf4eb66b Diagnose cases where the definition of a particular type is required,
is known (to Clang), but is not visible because the module has not yet
been imported.

llvm-svn: 147436
2012-01-02 17:18:37 +00:00
Chandler Carruth 306bd2c6aa Fix PR11685 by implementing -ffast-math and its various friends in the
Clang driver. This involves a bunch of silly option parsing code to try
to carefully emulate GCC's options. Currently, this takes a conservative
approach, and unless all of the unsafe optimizations are enabled, none
of them are. The fine grained control doesn't seem particularly useful.
If it ever becomes useful, we can add that to LLVM first, and then
expose it here.

This also fixes a few tiny bugs in the flag management around
-fhonor-infinities and -fhonor-nans; the flags now form proper sets both
for enabling and disabling, with the last flag winning.

I've also implemented a moderately terrifying GCC feature where
a language change is also provided by the '-ffast-math' flag by defining
the __FAST_MATH__ preprocessor macro. This feature is tracked and
serialized in the frontend but it isn't used yet. A subsequent patch
will add the preprocessor macro and tests for it.

I've manually tested that codegen appears to respect this, but I've not
dug in enough to see if there is an easy way to test codegen options w/o
relying on the particulars of LLVM's optimizations.

llvm-svn: 147434
2012-01-02 14:19:45 +00:00
Abramo Bagnara 7079d7e310 Added a missing case for -Wdisabled-macro-expansion.
llvm-svn: 147433
2012-01-02 10:08:26 +00:00
Rafael Espindola eeb9d9fef6 Small cosmetic cleanups in code I will change anyway.
llvm-svn: 147424
2012-01-02 06:26:22 +00:00
Douglas Gregor fe620daefa Eliminate ObjCProtocolDecl's end-of-definition location. It is not
used anywhere.

llvm-svn: 147422
2012-01-02 02:22:52 +00:00
Douglas Gregor cf9f3ea6f9 Fix canonicalization of protocol-qualified types
llvm-svn: 147421
2012-01-02 02:00:30 +00:00
Douglas Gregor 1bd9617671 Move ObjCProtocolDecl::EndLoc into its DefinitionData, and give
ObjCProtocolDecl proper source-range information.

llvm-svn: 147420
2012-01-02 01:18:16 +00:00
Douglas Gregor 05a1f4d60b Eliminate the ForwardDecl/InitiallyForwardDecl bits from ObjCProtocolDecl. They are no longer needed
llvm-svn: 147419
2012-01-01 22:06:18 +00:00
Abramo Bagnara 123bec89ab Added -Wdisabled-macro-expansion warning.
llvm-svn: 147418
2012-01-01 22:01:04 +00:00
Douglas Gregor da38930cf3 Implement declaration merging for Objective-C protocols across
multiple, disjoint modules. There is far too much duplicating with the
ObjCInterfaceDecl case here, which I'll eliminate shortly.

llvm-svn: 147417
2012-01-01 21:47:52 +00:00
Douglas Gregor a503bb9ce4 Eliminate redundant, empty function
llvm-svn: 147416
2012-01-01 21:39:12 +00:00
Douglas Gregor f610267581 Eliminate ObjCForwardProtocolDecl, which is redundant now that
ObjCProtocolDecl modules forward declarations properly.

llvm-svn: 147415
2012-01-01 21:23:57 +00:00
Douglas Gregor c51118238c Don't bother rewriting an Objective-C class or protocol declaration to the module file when we've merely added a definition
llvm-svn: 147414
2012-01-01 20:35:33 +00:00
Douglas Gregor 42ff1bb922 Eliminate ASTMutationListener::UpdatedAttributeList, which is no
longer needed now that we aren't back-patching ObjCProtocolDecls.

llvm-svn: 147413
2012-01-01 20:33:24 +00:00
Douglas Gregor 32c1757730 Wire up redeclaration chains for Objective-C protocols, so that both
forward declarations and definitions of an Objective-C protocol are
represented within a single chain of ObjCProtocolDecls.

llvm-svn: 147412
2012-01-01 20:30:41 +00:00
Douglas Gregor a715bfff98 Introduce the core infrastructure needed to model redeclaration chains
for Objective-C protocols, including:
  - Using the first declaration as the canonical declaration
  - Using the definition as the primary DeclContext
  - Making sure that all declarations have a pointer to the definition
  data, and that we know which declaration is the definition
  - Serialization support for redeclaration chains and for adding
  definitions to already-serialized declarations.

However, note that we're not taking advantage of much of this code
yet, because we're still re-using ObjCProtocolDecls.

llvm-svn: 147410
2012-01-01 19:51:50 +00:00
Douglas Gregor e6e48b1490 Move the data that corresponds to the definition of a protocol into a
separately-allocated DefinitionData structure. Introduce various
functions that will help with the separation of declarations from
definitions (isThisDeclarationADefinition(), hasDefinition(),
getDefinition()).

llvm-svn: 147408
2012-01-01 19:29:29 +00:00
Rafael Espindola 01fb1135d6 Use hasSameType.
llvm-svn: 147407
2012-01-01 18:36:59 +00:00
Douglas Gregor 33b2429bf3 Use declaresSameEntity() when comparing ObjCProtocolDecls, and
getCanonicalDecl() when putting ObjCProtocolDecls into a set. This is
groundwork for making ObjCProtocolDecl redeclarable.

llvm-svn: 147406
2012-01-01 18:09:12 +00:00
Rafael Espindola 0f960a0a5a Consider visibility attributes in namespaces as being explicit. I.e., they
take precedence over command line options. Fixes PR10113.

llvm-svn: 147405
2012-01-01 18:06:40 +00:00
Rafael Espindola 09593a322a Replace a isa+cast with a dyn_cast.
llvm-svn: 147401
2012-01-01 17:48:19 +00:00