Douglas Gregor [Thu, 24 Mar 2011 14:35:16 +0000 (14:35 +0000)]
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
John McCall [Thu, 24 Mar 2011 11:26:52 +0000 (11:26 +0000)]
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.
Douglas Gregor [Thu, 24 Mar 2011 10:35:39 +0000 (10:35 +0000)]
Fix the insertion of label declarations into the identifier chain in
the case where we only have a single identifier with that name in the
chain. Fixes PR9463 for real this time.
David Chisnall [Wed, 23 Mar 2011 22:52:06 +0000 (22:52 +0000)]
Fixed type error in last commit (forgot that now that selectors are not
accessed via the indirect pointer, they don't need to be pointers to pointers).
Finished moving the message lookup code into separate subclasses for each
runtime. Also performed a few smallish related tidies.
We're now bitcasting the result of the message lookup functions, rather than
casting the lookup functions themselves, so the messages.m test needed updating
to reflect this.
Ted Kremenek [Wed, 23 Mar 2011 21:33:21 +0000 (21:33 +0000)]
Fix CFG-construction bug when run from AnalysisBasedWarnings::IssueWarnings() where block-level expressions that need
to be recorded in the Stmt*->CFGBlock* map were not always done so. Fixes <rdar://problem/9171946>.
David Chisnall [Wed, 23 Mar 2011 16:36:54 +0000 (16:36 +0000)]
Initial work on refactoring GNU runtime code (long overdue - it's quite obvious
that I hadn't used C++ for several years before writing most of this code).
Still lots more to do. This set of changes includes:
- Remove the distinction between typed and untyped selectors. More accurately
reflect what the runtime does, by using typed selectors everywhere, with an
empty type field if the types are unknown. Now we just store a small list of
types for each selector (in theory, this should always be exactly one, but
this constraint was not enforced back in 1986 when it should have been).
- Add some consistency to how runtime functions are created. These are all
generated via the LazyRuntimeFunction class (which might be useful outside
CGObjCGNU - feel free to move it into a header if it is). This function
stores the types of a function, looks it up the first time it's used, and
caches the result. This means that we're now not wasting time constructing
the llvm::FunctionType every time some of the functions are looked up, but
also not inserting references to runtime functions into the module if they're
not actually used.
- Started separating out the fragile and non-fragile ABI behaviours into two
subclasses of CGObjCGNU: CGObjCGCC for the legacy GCC runtime ABI and
CGObjCGNUstep for the new GNUstep ABI. Not all of the differences in
behaviour are factored out yet, but they will be in future commits.
- Removed all of the CodeGen:: things: we've been using namespace CodeGen in
this file for ages, so having explicit namespace specifiers is just a bit
confusing.
- Added a few more comments.
- Used llvm::StringRef instead of std::string in a few places.
- Finally got around to storing the module path in the module structure. The
ABI says that the compiler should do this, although it's not used in the
runtime or exposed outside the runtime, so it's pretty useless.
Still to do:
- We currently have two code paths for generating try blocks, one for ObjC and
one for ObjC++. Not only are these substantially similar, they are also very
similar to the CGObjCMac version. These need factoring out into a single
parameterised implementation, either in CGObjCRuntime or CodeGenFunction.
The EmitObjCXXTryStmt() function was added so that the changes to fix a bug
in time for the 2.9 release would be self-contained and reduce the chances of
breaking anything else, but these should be done properly as soon as
possible.
- Split up some large functions (e.g. GenerateClass()) into smaller functions
for generating the various data structures.
- The method lookup code into the two subclasses, removing the conditionals in
the message send functions.
- Add doxygen comments on the remaining undocumented functions.
- We seem to be generating global pointer variables for selectors, then storing
a pointer to the selector, then generating a load of this pointer (and then a
load of the real selector later) every time a static selector is used. I can
only assume I was asleep or drunk when I did this - we should just be
referencing the selectors directly in the selector array.
Douglas Gregor [Wed, 23 Mar 2011 15:13:44 +0000 (15:13 +0000)]
Teach DelayedDiagnostic to copy its string, rather than hope that the
string itself lives longer than the DelayedDiagnostic. Fixes a recent
use-after-free regression due to my availability attribute work.
Ted Kremenek [Wed, 23 Mar 2011 02:16:44 +0000 (02:16 +0000)]
Fix crash in clang_getInstantiationLoc() when SourceManager::getInstantiationLoc() can return a SourceLocatin with an invalid
FileID on invalid code. Fixes <rdar://problem/9164623>.
says that the function "foo" was introduced in 10.2, deprecated in
10.4, and completely obsoleted in 10.6. This attribute ties in with
the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that
we want to deploy back to Mac OS X 10.1). There are several concrete
behaviors that this attribute enables, as illustrated with the
function foo() above:
- If we choose a deployment target >= Mac OS X 10.4, uses of "foo"
will result in a deprecation warning, as if we had placed
attribute((deprecated)) on it (but with a better diagnostic)
- If we choose a deployment target >= Mac OS X 10.6, uses of "foo"
will result in an "unavailable" warning (in C)/error (in C++), as
if we had placed attribute((unavailable)) on it
- If we choose a deployment target prior to 10.2, foo() is
weak-imported (if it is a kind of entity that can be weak
imported), as if we had placed the weak_import attribute on it.
Naturally, there can be multiple availability attributes on a
declaration, for different platforms; only the current platform
matters when checking availability attributes.
The only platforms this attribute currently works for are "ios" and
"macosx", since we already have -mxxxx-version-min flags for them and we
have experience there with macro tricks translating down to the
deprecated/unavailable/weak_import attributes. The end goal is to open
this up to other platforms, and even extension to other "platforms"
that are really libraries (say, through a #pragma clang
define_system), but that hasn't yet been designed and we may want to
shake out more issues with this narrower problem first.
John McCall [Tue, 22 Mar 2011 23:15:50 +0000 (23:15 +0000)]
Fix an error with the declaration of block parameters that depend
on previous block parameters that crept in as part of my captures
work a month or so ago.
David Chisnall [Tue, 22 Mar 2011 20:03:13 +0000 (20:03 +0000)]
Make the property accessor functions that take a ptrdiff_t actually take a ptrdiff_t instead of a long (should have no impact on any sane platforms, but win64 is not sane).
David Chisnall [Tue, 22 Mar 2011 19:57:51 +0000 (19:57 +0000)]
Make the ivar offset always be a ptrdiff_t, because stuff in CGObjC.cpp expects this. Actually, it expects a long, but that's a bug that will be fixed in the next commit...
Daniel Dunbar [Tue, 22 Mar 2011 16:48:17 +0000 (16:48 +0000)]
Frontend: Add a more explicit -backend-option flag for passing backend command
line options, instead of leveraging the blanket -mllvm option.
- This allows using the frontend itself without requiring the backend have
those options available (i.e., if the target wasn't built).
John McCall [Tue, 22 Mar 2011 07:05:39 +0000 (07:05 +0000)]
The emission of an Objective-C++'s class .cxx_destruct method should be
conditioned on whether it has any destructible ivars, not on whether
it has any non-trivial class-object initializers.
John McCall [Tue, 22 Mar 2011 06:34:45 +0000 (06:34 +0000)]
File-scope static functions need to be mangled with 'L' so that
they don't collide with file-scope extern functions from the same
translation unit. This is basically a matter of applying the same
logic to FunctionDecls as we were previously applying to VarDecls.
Ted Kremenek [Tue, 22 Mar 2011 01:15:24 +0000 (01:15 +0000)]
Rework crash recovery cleanup in ASTUnit and CIndex to recover more memory during a Sema crash (we have just a handful of leaks left)
and to use the simplified cleanup registration API.
Ted Kremenek [Mon, 21 Mar 2011 18:40:17 +0000 (18:40 +0000)]
Improve crash recovery cleanup to recovery CompilerInstances during crash recovery. This was a huge resource "root" during crashes.
This change requires making a bunch of fundamental Clang structures (optionally) reference counted to allow correct
ownership semantics of these objects (e.g., ASTContext) to play out between an active ASTUnit and CompilerInstance
object.
Introduce FindTargetProgramPath to check for a target-specific helper
program and fallback to plain version otherwise. Use this for the NetBSD
target to make it try e.g. i486--netbsdelf-as and -ld for target
i486--netbsdelf.
Memorize presence/absence of -nostdlib in Driver.
Drop program paths on NetBSD (unused). Only include lib dir, if
-nostdlib is absent. Use = to allow --sysroot to work.
Ted Kremenek [Fri, 18 Mar 2011 23:05:39 +0000 (23:05 +0000)]
Add libclang hook 'clang_toggleCrashRecovery()', which provides a mechanism for a client to enable/disable CrashRecovery within libclang function calls.
Add support for language-specific address spaces. On top of that,
add support for the OpenCL __private, __local, __constant and
__global address spaces, as well as the __read_only, _read_write and
__write_only image access specifiers. Patch originally by ARM;
language-specific address space support by myself.
Ted Kremenek [Fri, 18 Mar 2011 22:11:40 +0000 (22:11 +0000)]
Remove '-Xclang' and '-mllvm' entries from Clang man page. The later is only available in debug builds and the former is not supposed to be used by end-users.
Daniel Dunbar [Fri, 18 Mar 2011 21:23:40 +0000 (21:23 +0000)]
Driver: Forward -traditional and -traditional-cpp in preprocessing modes.
- We don't really support the majority of the horrible -traditional-cpp
behavior, but it is unlikely that we ever will either. This allows us to
start trying to use clang as a /usr/bin/cpp replacement and see what pieces
of -traditional-cpp mode people actually care about.