Commit Graph

34252 Commits

Author SHA1 Message Date
Richard Trieu caff247882 Add feature to diagnostics that will provide more information on function
pointer mismatch.  Cases covered are: initialization, assignment, and function
arguments.  Additional text will give the extra information about the nature
of the mismatch: different classes for member functions, wrong number of
parameters, different parameter type, different return type, and function
qualifier mismatch.

llvm-svn: 145114
2011-11-23 22:32:32 +00:00
Argyrios Kyrtzidis a72450057b [PCH] Check for isTopLevelDeclInObjCContainer when picking abbreviations.
llvm-svn: 145110
2011-11-23 21:11:23 +00:00
Argyrios Kyrtzidis 8ad3bab505 [libclang] Fix operations (token annotation, getting cursor, etc.) with a file region
inside an objc container that "contains" other file-level declarations.

When getting the array of file-level declarations that overlap with a file region,
we failed to report that the region overlaps with an objc container, if
the container had other file-level declarations declared lexically inside it.

Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST
and handling them appropriately.

llvm-svn: 145109
2011-11-23 20:27:36 +00:00
Argyrios Kyrtzidis e4d082827d Remove an assertion that is not valid if we cancel parsing.
llvm-svn: 145108
2011-11-23 20:27:29 +00:00
Argyrios Kyrtzidis 41fc05cad8 [libclang] Indexing API: Fix issues, mostly C++ related.
llvm-svn: 145107
2011-11-23 20:27:26 +00:00
James Molloy c445be4b4b AAPCS compliance - 32-bit wchar_t should be unsigned for both aapcs and aapcs-linux.
Original behaviour of defining wchar_t as signed int has been kept for apcs-gnu as I don't have any spec for this to validate against.

llvm-svn: 145102
2011-11-23 13:35:08 +00:00
Richard Smith 514f7e9cb9 Don't check alignment, it's irrelevant to this test.
llvm-svn: 145093
2011-11-23 02:12:00 +00:00
Richard Smith 2d988f0f05 Use static storage duration for file-scope compound literals, even when they
appear in non-constant initializers in C++.

llvm-svn: 145087
2011-11-22 22:48:32 +00:00
Benjamin Kramer 900f1defdd Remove assert from hot code path and add a clarifying comment.
The assert wasn't adding much value but slowed down Release+Asserts builds.

llvm-svn: 145082
2011-11-22 20:39:31 +00:00
Matt Beaumont-Gay 31fcb9f291 Provide better source info for template specializations with non-type arguments.
This fixes a crasher in tools like Include-What-You-Use which examine such
arguments. Patch from Dean Sturtevant at Google!

llvm-svn: 145077
2011-11-22 20:00:10 +00:00
Benjamin Kramer 3885737a1b Lexer: Don't throw away the hard work SSE did to find a slash.
We can reuse the information and avoid looping over all the bytes again.

llvm-svn: 145070
2011-11-22 18:56:46 +00:00
Argyrios Kyrtzidis 4c910b1475 [libclang] Indexing API: Support C++ symbols.
llvm-svn: 145058
2011-11-22 07:24:51 +00:00
Kostya Serebryany c3333e879f implement __has_feature(address_sanitizer); also use LangOpts.AddressSanitizer instead of CodeGenOpts.AddressSanitizer
llvm-svn: 145054
2011-11-22 01:28:36 +00:00
Peter Collingbourne 6e6e52b58a Un-XFAIL this test on Darwin, it reportedly passes now.
llvm-svn: 145052
2011-11-21 21:56:51 +00:00
Richard Smith f13b855809 Add stub section to the user manual for C++ language features, and document
-ftemplate-depth= and -fconstexpr-depth= in it.

llvm-svn: 145049
2011-11-21 20:54:59 +00:00
Richard Smith 9a56882e53 Add driver arguments -ftemplate-depth=N and -fconstexpr-depth=N, with the same
semantics and defaults as the corresponding g++ arguments. The historical g++
argument -ftemplate-depth-N is kept for compatibility, but modern g++ versions
no longer document that option.

Add -cc1 argument -fconstexpr-depth N to implement the corresponding
functionality.

The -ftemplate-depth=N part of this fixes PR9890.

llvm-svn: 145045
2011-11-21 19:36:32 +00:00
Roman Divacky d150ad3f07 Change the linker emulation name for FreeBSD/PPC32.
Submitted by Andreas Tobler!

llvm-svn: 145041
2011-11-21 16:50:32 +00:00
Benjamin Kramer 5642e19065 CodeGen: Simplify code.
llvm-svn: 145040
2011-11-21 15:47:23 +00:00
Peter Collingbourne 0e7e3fc130 Delete the depfile if we could not open a header file. We cannot
generate any reasonable depfile if a header is missing.

llvm-svn: 145019
2011-11-21 00:01:14 +00:00
Peter Collingbourne 119cfaa595 Teach the driver about failure result files, which are compilation
output files that are valid regardless of whether the compilation
succeeded or failed (but not if we crash).  Add depfiles to the
failure result file list.

llvm-svn: 145018
2011-11-21 00:01:05 +00:00
Peter Collingbourne 17a7bbbc9f Create the clang++ symlink as a POST_BUILD custom command on clang.
This saves us from re-creating the symlink on every build even if we
didn't rebuild clang.

llvm-svn: 145017
2011-11-21 00:00:48 +00:00
Benjamin Kramer ddbb2b85ab CodeGen: allow __asm renaming on static local variables.
Fixes PR4777.

llvm-svn: 145015
2011-11-20 21:05:04 +00:00
Douglas Gregor 8ad31c2e36 Allow preprocessor callbacks to recover from a "file not found" error,
from Jason Haslam!

llvm-svn: 145012
2011-11-20 17:46:46 +00:00
Douglas Gregor 49ccfaa938 Add support for pretty-printing attributes, from Richard Membarth!
llvm-svn: 145002
2011-11-19 19:22:57 +00:00
Douglas Gregor 9f39a765e2 Update signature of HandleTopLevelDecl.
llvm-svn: 145001
2011-11-19 19:22:13 +00:00
Douglas Gregor 328d8d255e Tweak the guidelines for when one should send patches to cfe-commits vs. cfe-dev
llvm-svn: 145000
2011-11-19 19:14:26 +00:00
Abramo Bagnara 5001caa1b6 Fixed HadMultipleCandidates loading.
llvm-svn: 144995
2011-11-19 11:44:21 +00:00
Benjamin Kramer 7824360017 Driver: Remove the signal number from the "command failed" diagnostic.
- With the current implementation of sys::Program this always printed "2".
- The command execution code will output the right number anyway (including the signal name).

llvm-svn: 144993
2011-11-19 10:24:49 +00:00
Douglas Gregor 6cdda3bde6 Initialize ImplicitConversionSequence::ListInitializationSequence. Fixes PR11394
llvm-svn: 144992
2011-11-19 09:56:57 +00:00
Douglas Gregor 3005bfd516 Add missing initialization in the ContentCache. Seriously, when do
constructors go below public member functions?

llvm-svn: 144991
2011-11-19 09:42:42 +00:00
Francois Pichet 6dc4c16417 Enable delayed template parsing for friend functions declared at template class scope.
llvm-svn: 144980
2011-11-18 23:47:17 +00:00
Abramo Bagnara 12dcbf3eaa Fixed implicit instantiations source range.
llvm-svn: 144977
2011-11-18 08:08:52 +00:00
Ted Kremenek 2acedbd417 Refine placement of LangOptions object in CompilerInvocation by adding a new baseclass CompilerInvocationBase with a custom copy constructor. This ensures that whenever the CompilerInvocation object's copy constructor is used we always clone the LangOptions object.
llvm-svn: 144973
2011-11-18 04:32:13 +00:00
Eli Friedman f22fa9eaef Finish r144971, which was an incomplete commit.
llvm-svn: 144972
2011-11-18 04:01:36 +00:00
Eli Friedman 0b3f201b61 Fix the meaning of an "empty" record for the case of a zero-length array. Use isEmptyRecord for arguments on x86-32; there are structs of size 0 which don't count as empty.
llvm-svn: 144971
2011-11-18 03:47:20 +00:00
Eli Friedman a1748564b4 Make va_arg on x86-64 compute alignment the same way as argument passing.
Fixes <rdar://problem/10463281>.

llvm-svn: 144966
2011-11-18 02:44:19 +00:00
Anna Zaks 457c68726c [analyzer] Warn when non pointer arguments are passed to scanf (only when running taint checker).
There is an open radar to implement better scanf checking as a Sema warning. However, a bit of redundancy is fine in this case.

llvm-svn: 144964
2011-11-18 02:26:36 +00:00
Eli Friedman 1d7dd3b682 A bunch of fixes to argument passing and va_arg on Darwin x86-32 for structures containing an SSE vector.
llvm-svn: 144963
2011-11-18 02:12:09 +00:00
Eli Friedman e5c85622c9 Don't try to expand struct arguments containing holes on x86-32. From gcc struct layout tests.
llvm-svn: 144961
2011-11-18 01:32:26 +00:00
Eli Friedman ee94534662 Simplify code for returning a struct for Darwin x86-32 ABI. Use a better type for a function returning a struct containing only a pointer. Handle the edge case of a struct containing only a float or double plus some dead padding instead of asserting.
llvm-svn: 144960
2011-11-18 01:25:50 +00:00
NAKAMURA Takumi 2a4859aeff c-index-test.c: Fix syntax according to C.
llvm-svn: 144947
2011-11-18 00:51:03 +00:00
Anna Zaks 1df54a8bc8 [analyzer] The compiler warning was disabling the analyzer in this test.
llvm-svn: 144946
2011-11-18 00:45:20 +00:00
Eli Friedman 9f061a37bb Ignore empty unions in argument lowering on x86-32. From gcc struct layout tests.
llvm-svn: 144944
2011-11-18 00:28:11 +00:00
Argyrios Kyrtzidis 841dd8861a Change ASTConsumer::HandleTopLevelDecl to return true for the parser to continue
parsing or false to abort parsing.

llvm-svn: 144943
2011-11-18 00:26:59 +00:00
Argyrios Kyrtzidis effdbf55ac [libclang] Indexing API:
-For indexDeclaration, also pass the declaration attributes as an array of cursors.
-Rename CXIndexOpt_OneRefPerFile -> CXIndexOpt_SuppressRedundantRefs, and only pass
  a reference if a declaration/definition does not exist in the file.
-Other fixes.

llvm-svn: 144942
2011-11-18 00:26:51 +00:00
Argyrios Kyrtzidis 1cff795e51 [libclang] Indexing API: make sure we don't pass declarations/references without USR or location.
llvm-svn: 144941
2011-11-18 00:26:46 +00:00
Eric Christopher 459532e1d5 Use the canonical decl to index so that we can really find it later.
Fixes rdar://10433202

llvm-svn: 144938
2011-11-17 23:45:00 +00:00
Sean Callanan 651982790a Added a clause to the ASTImporter allowing it to
import TranslationUnitDecls.

llvm-svn: 144934
2011-11-17 23:20:56 +00:00
Anna Zaks 040ddfedc0 [analyzer] Do not conjure a symbol when we need to propagate taint.
When the solver and SValBuilder cannot reason about symbolic expressions (ex: (x+1)*y ), the analyzer conjures a new symbol with no ties to the past. This helps it to recover some path-sensitivity. However, this breaks the taint propagation.

With this commit, we are going to construct the expression even if we cannot reason about it later on if an operand is tainted.

Also added some comments and asserts.

llvm-svn: 144932
2011-11-17 23:07:28 +00:00
Ted Kremenek 8cf47df72f Make 'LangOptions' in CompilerInvocation a heap-allocated, reference counted object. I discovered that llvm::RefCountedBase<T> has
a bug where the reference count is copied in the copy constructor, which means that there were cases when the CompilerInvocation
objects created by ASTUnit were actually leaked.  When I fixed that bug locally, it showed that a whole bunch of code assumed
that the LangOptions object that was part of CompilerInvocation was still alive.  By making it heap-allocated and reference counted,
we can keep it around after the CompilerInvocation object goes away.

As part of this change, change CompilerInvocation:getLangOptions() to return a pointer, acting as another clue that this
object may outlive the CompilerInvocation object.

This commit doesn't fix the CompilerInvocation leak itself.  That will come when I commit the fix to llvm::RefCountedBase<T> to
mainline LLVM.

llvm-svn: 144930
2011-11-17 23:01:24 +00:00
Ted Kremenek 250476021f Simplify crash cleanup logic in ASTUnit::LoadFromCommandLine() by zeroing out two IntrusiveRefCnt pointers after we have assigned their respective values into fields of ASTUnit.
llvm-svn: 144929
2011-11-17 23:01:17 +00:00
Anna Zaks 89c00c9d3f [analyzer] Minor tweaks to the ProgramState::isTainted().
llvm-svn: 144928
2011-11-17 22:59:00 +00:00
Anna Zaks af36e9128a [analyzer] Add a helper method.
Naming could be improved.. But we should first rename the classes in the SVal hierarchy.

llvm-svn: 144927
2011-11-17 22:57:01 +00:00
Richard Smith 027bf11eb3 Constant expression evaluation: add support for evaluation of member pointers
and base-to-derived casts, and add proper handling of temporaries.

llvm-svn: 144926
2011-11-17 22:56:20 +00:00
Douglas Gregor c04f644311 When making a suggestion regarding which module to load rather than
preprocess/parse a header, report back with an actual module (which
may be a submodule) rather than just the name of the module.

llvm-svn: 144925
2011-11-17 22:44:56 +00:00
Douglas Gregor 755b205519 Add the notion of "framework" modules to module maps. Framework
modules (obviously) describe frameworks, and understand the header
layout of frameworks.

llvm-svn: 144921
2011-11-17 22:09:43 +00:00
Douglas Gregor be51458dc3 If we're dealing with an overridden buffer in the AST reader, load the
file as a virtual file with the stored modification time and size.

llvm-svn: 144916
2011-11-17 19:08:51 +00:00
NAKAMURA Takumi 74793710c1 docs/UsersManual.html: Remove obsolete mingw issue.
llvm-svn: 144897
2011-11-17 07:54:13 +00:00
NAKAMURA Takumi 5dd3777633 test/Frontend/dependency-gen.c: Relax expressions for Win32 host (mingw msys).
llvm-svn: 144887
2011-11-17 07:21:33 +00:00
NAKAMURA Takumi 32f1acf14a Revert r132539 for now, "My testing shows that function stat has no problem with trailing separators. (tested on Windows and Darwin)."
It caused PR10331. MSVCRT stat() cannot strip trailing '/'. (can '\')

llvm-svn: 144884
2011-11-17 06:16:05 +00:00
David Blaikie 0f65d59e52 Include named unions in union member init checking
llvm-svn: 144883
2011-11-17 06:01:57 +00:00
Francois Pichet 857f9d6e5e In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside default argument instantiation.
This is a little bit tricky because during default argument instantiation the CurContext points to a CXXMethodDecl but we can't use the keyword this or have an implicit member call generated.

This fixes 2 errors when parsing MFC code with clang.

llvm-svn: 144881
2011-11-17 03:44:24 +00:00
Douglas Gregor 5acdf59ebc Actually free memory for the module maps
llvm-svn: 144880
2011-11-17 02:05:44 +00:00
Douglas Gregor 667971778c Try to appease the failing buildbot where I can't reproduce the problem
llvm-svn: 144879
2011-11-17 01:44:33 +00:00
Douglas Gregor 56c6401306 When we're loading a framework header, first try to turn the framework
into a module. This module can either be loaded from a module map in
the framework directory (which isn't quite working yet) or inferred
from an umbrella header (which does work, and replaces the existing
hack).

llvm-svn: 144877
2011-11-17 01:41:17 +00:00
Anna Zaks df6ca9fbee [analysis] Constify CheckerContext.
llvm-svn: 144871
2011-11-17 01:09:19 +00:00
Anna Zaks 871606d8de [analyzer] Put CheckerConext::getCalleeName out of line.
llvm-svn: 144870
2011-11-17 01:09:15 +00:00
Daniel Dunbar 4f41440cf9 clang/Darwin: Use the compiler-rt provided profile library.
llvm-svn: 144869
2011-11-17 00:36:57 +00:00
Daniel Dunbar e285a7d3f0 tests/Driver/darwin-ld.c: Get rid of the "splatter" test case. We have enough
other coverage that actually properly checks features such that this test is not
really adding value anymore.

llvm-svn: 144868
2011-11-17 00:36:53 +00:00
Douglas Gregor b2ac5517b5 Add missing header for modules test.
llvm-svn: 144862
2011-11-16 23:41:39 +00:00
Daniel Dunbar a8c9886dcc build/make/compiler-rt: Don't attempt to build compiler-rt runtime libraries
when cross compiling under the current organization.
 - See verbose comment for explanation, justification, and how to fix.

llvm-svn: 144860
2011-11-16 23:22:07 +00:00
Douglas Gregor b65dbfff52 A module with an umbrella header assumes that all of the headers in
the umbrella header's directory and its subdirectories are part of the
module (that's why it's an umbrella). Make sure that these headers are
considered to be part of the module for lookup purposes.

llvm-svn: 144859
2011-11-16 23:02:25 +00:00
Abramo Bagnara b0cf297654 Added missing ImplicitCastExpr around conversion operator call.
llvm-svn: 144850
2011-11-16 22:46:05 +00:00
Bob Wilson 89d14247ff Fix Neon builtin pointer argument checking for "sret" builtins.
The code for checking Neon builtin pointer argument types was assuming that
there would only be one pointer argument.  But, for vld2-4 builtins, the first
argument is a special sret pointer where the result will be stored.  So,
instead of scanning all the arguments to find a pointer, have TableGen figure
out the index of the pointer argument that needs checking.  That's better than
scanning all the arguments regardless.  <rdar://problem/10448804>

llvm-svn: 144834
2011-11-16 21:32:23 +00:00
Jim Goodnow II 8d21fc8239 Fixed crash with initializer lists and unnamed bitfields in the RegionStore
Manager. Added test to ensure proper binding of initialized values.
This patch fixes PR11249.

llvm-svn: 144831
2011-11-16 20:29:27 +00:00
Douglas Gregor 9dc3212f98 Implement (de-)serialization of the buffer contents for an overridden
file in the source manager. This allows us to properly create and use
modules described by module map files without umbrella headers (or
with incompletely umbrella headers). More generally, we can actually
build a PCH file that makes use of  file -> buffer remappings, which
could be useful in libclang in the future.

llvm-svn: 144830
2011-11-16 20:05:18 +00:00
Benjamin Kramer de2ac70c0a Update CMake build.
llvm-svn: 144829
2011-11-16 20:05:08 +00:00
Anna Zaks 20829c90be [analyzer] Catch the first taint propagation implied buffer overflow.
Change the ArrayBoundCheckerV2 to be more aggressive in reporting buffer overflows
when the offset is tainted. Previously, we did not report bugs when the state was
underconstrained (not enough information about the bound to determine if there is
an overflow) to avoid false positives. However, if we know that the buffer
offset is tainted - comes in from the user space and can be anything, we should
report it as a bug.

+ The very first example of us catching a taint related bug.
This is the only example we can currently handle. More to come...

llvm-svn: 144826
2011-11-16 19:58:17 +00:00
Anna Zaks 5c5bf9b634 [analyzer] Adding generic taint checker.
The checker is responsible for defining attack surface and adding taint to symbols.

llvm-svn: 144825
2011-11-16 19:58:13 +00:00
Anna Zaks ec7dc5c137 [analyzer] Adding basic building blocks for taint propagation.
TaintTag.h will contain definitions of different taint kinds and their properties.
TaintManager will be responsible for implementing taint specific operations, storing taint.
ProgramState will provide API to add/remove taint.

llvm-svn: 144824
2011-11-16 19:58:10 +00:00
Anna Zaks 6b1a955130 [analyzer] Cleanup: Null->0, comments.
llvm-svn: 144823
2011-11-16 19:58:05 +00:00
Anna Zaks d254dece12 [analyzer] Cleanup (NULL -> 0, no doxygen in cpp).
llvm-svn: 144822
2011-11-16 19:58:02 +00:00
Anna Zaks 4f6c0e0cf6 [analyzer] Assert if we ever get an over constrained state.
llvm-svn: 144821
2011-11-16 19:57:59 +00:00
Anna Zaks 3888aa4beb [analyzer] Factor getCalleeName to the checker context.
many checkers are trying to get a name of the callee when visiting
a CallExpr, so provide a convenience API.

llvm-svn: 144820
2011-11-16 19:57:55 +00:00
Chandler Carruth 74f0df442b Stop claiming that Visual Studio 2005 is a viable basis for building
Clang. It isn't any more, and we're not going to twist the code around
to make it work.

llvm-svn: 144815
2011-11-16 19:29:07 +00:00
Kostya Serebryany 8855ff61cb Add -f[no-]address-sanitizer flag
llvm-svn: 144800
2011-11-16 17:34:26 +00:00
Richard Smith 10f4d06b81 PR11391: Don't try to evaluate the LHS of a _Complex assignment as an rvalue.
llvm-svn: 144799
2011-11-16 17:22:48 +00:00
Douglas Gregor 4332b32c5e When building a module from a module map that isn't simply an umbrella
header, create our own in-memory buffer to parse all of the
appropriate headers, and use that to build the module. This isn't
end-to-end testable yet; that's coming next.

llvm-svn: 144797
2011-11-16 17:04:00 +00:00
Abramo Bagnara d4756b9ece Fixed missing cast and wrong cast kind in delete expression.
llvm-svn: 144796
2011-11-16 15:42:13 +00:00
Douglas Gregor 4ba7c2abc2 Switch the remaining modules tests over to -emit-module-from-map.
llvm-svn: 144795
2011-11-16 15:22:03 +00:00
Argyrios Kyrtzidis 7ae5d9c4c0 [libclang] Add a comment in lazyCreateDiags to explain why the check and reset of
diagnostic set is necessary.

llvm-svn: 144793
2011-11-16 08:59:00 +00:00
Argyrios Kyrtzidis 463741a5a2 [libclang] Make clang_annotateTokens use "file-targeted" deserialization and avoid
unnecessary deserializations.

llvm-svn: 144792
2011-11-16 08:58:57 +00:00
Argyrios Kyrtzidis c504eb3448 [libclang] Make clang_findReferencesInFile use "file-targeted" deserialization and avoid
unnecessary deserializations.

llvm-svn: 144791
2011-11-16 08:58:54 +00:00
Evan Cheng dd286bce2c Match LLVM API change.
llvm-svn: 144789
2011-11-16 08:38:55 +00:00
Richard Smith cf74da76db Fix PR11385: A pointer constant expression which has been cast via an integer is
not safely derived. Don't allow lvalue-to-rvalue conversions on the result of
dereferencing such a pointer.

llvm-svn: 144783
2011-11-16 07:18:12 +00:00
Douglas Gregor 84febf4a4d Migrate a few more modules tests over to -emit-module-from-map.
llvm-svn: 144779
2011-11-16 05:16:30 +00:00
Ted Kremenek 0e9843b328 Teach ccc-analyzer about -fobjc-arc.
llvm-svn: 144778
2011-11-16 05:14:42 +00:00
Argyrios Kyrtzidis 516eec2d8b [libclang] Fix crash on invalid code. Fixes rdar://10451854
llvm-svn: 144766
2011-11-16 02:35:10 +00:00
Argyrios Kyrtzidis df15c20979 [libclang] Indexing API: fill the objc category info for a category implementation and
do not crash if no client container is registered for a declaration context.

llvm-svn: 144765
2011-11-16 02:35:05 +00:00
Argyrios Kyrtzidis d7b8790003 [libclang] Indexing API: make sure we do not try to index local declarations.
llvm-svn: 144764
2011-11-16 02:35:01 +00:00
Argyrios Kyrtzidis e4acd23f0b [libclang] Indexing API: if the CXIndexOpt_OneRefPerFile option is set, only report one reference
per file.

llvm-svn: 144763
2011-11-16 02:34:59 +00:00
Argyrios Kyrtzidis f03e734876 [libclang] In lazyCreateDiags, recreate the diagnostic set if the number of diagnostics
in the ASTUnit changed.

llvm-svn: 144762
2011-11-16 02:34:55 +00:00
Eli Friedman aa9512c484 Fix test on Release builds.
llvm-svn: 144761
2011-11-16 02:19:03 +00:00
Eli Friedman d20adbdce3 Fix a bunch of really nasty bugs in how we compute alignment for reference lvalues. PR11376.
llvm-svn: 144745
2011-11-16 00:42:57 +00:00
Douglas Gregor 81ac842151 Switch some more of the modules tests over to "-emit-module-from-map",
and remove stray fprintf.

llvm-svn: 144742
2011-11-16 00:21:54 +00:00
Douglas Gregor 2b20cb87f5 Add support for building a module from a module map to the -cc1
interface. This is currently limited to modules with umbrella
headers.

llvm-svn: 144736
2011-11-16 00:09:06 +00:00
Francois Pichet 78286b24fd In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside static functions.
llvm-svn: 144729
2011-11-15 23:33:34 +00:00
Douglas Gregor ac42ec6fc5 Revert r144703. It was a dumb idea anyway; will add the new bits more
incrementally with a new frontend action.

llvm-svn: 144723
2011-11-15 22:58:25 +00:00
Eli Friedman 4134073c4b Compute whether a class is trivial correctly for template classes with an explicitly deleted or defaulted special member. PR11387.
llvm-svn: 144715
2011-11-15 22:39:08 +00:00
Douglas Gregor 86b6f74217 Split GenerateModuleAction into its own action, which will start
differing from GeneratePCHAction fairly soon.

llvm-svn: 144703
2011-11-15 21:49:36 +00:00
Abramo Bagnara dc1646dc2b Fixed plausible overloads location.
llvm-svn: 144700
2011-11-15 21:43:28 +00:00
Douglas Gregor 7d106e423e Add a -cc1-level option -fmodule-name=<name>, which will be used when
building modules.

llvm-svn: 144680
2011-11-15 19:35:01 +00:00
Fariborz Jahanian 197a895e75 Remove one group'ed warning.
llvm-svn: 144678
2011-11-15 19:25:38 +00:00
Fariborz Jahanian 7359122ba5 Add -Wmismatched-method-attributes flag for when attributes in method definition and
their decl. do not match. // rdar://10448471

llvm-svn: 144676
2011-11-15 19:13:36 +00:00
Chad Rosier 1fede19ce9 Typo.
llvm-svn: 144672
2011-11-15 19:03:03 +00:00
Chad Rosier e35f9ddb4c Fix a regression from 143657. The second pass of the warning options should only be emitting
warnings/errors for unknown warning options.  getDiagnosticsInGroup returns false if the 
diagnostics is found and true otherwise.  Thus, if we're reporting and we have a valid 
diagnostic, we were actually setting the flag and causing mayhem.
rdar://10444207

llvm-svn: 144670
2011-11-15 18:57:32 +00:00
Douglas Gregor 6c8f07ff46 Teach the CFG builder how to properly destroy temporaries who
lifetimes have been extended via reference binding. The type of the
reference and the type of the temporary are not necessarily the same,
which could cause a crash. Fixes <rdar://problem/10398199>.

llvm-svn: 144646
2011-11-15 15:29:30 +00:00
Benjamin Kramer fee467a0d0 Validate DiagGroup names in TableGen, they're used as command line arguments so we don't want shell meta chars in there.
llvm-svn: 144645
2011-11-15 12:54:53 +00:00
Benjamin Kramer 176a5cb38a Warning option typo correction: When two options have the same edit_distance don't display either.
Also add a maximum edit distance threshold, so we don't correct "-Wx" to "-W#pragma-messages".

llvm-svn: 144644
2011-11-15 12:26:39 +00:00
Abramo Bagnara 9847e744e2 Fixed a cut&paste error introduced in r141336.
llvm-svn: 144637
2011-11-15 11:25:38 +00:00
Argyrios Kyrtzidis 5938650b13 [PCH] When serializing an PseudoObjectExpr or AtomicExpr, the serialization code must be set
otherwise it will crash with asserts on or it will be written as null pointer.

llvm-svn: 144626
2011-11-15 06:20:27 +00:00
Argyrios Kyrtzidis 233f12d9e2 [libclang] Indexing API: Pass an implicit ObjCInterfaceDecl (@implementation without @interface)
in a separate indexing callback than its implementation.

llvm-svn: 144625
2011-11-15 06:20:24 +00:00
Argyrios Kyrtzidis ae8e792fe2 Use Decl's isImplicit field to indicate whether an ObjCInterfaceDecl is 'ImplicitInterfaceDecl',
no need to store it in another field.

llvm-svn: 144624
2011-11-15 06:20:21 +00:00
Argyrios Kyrtzidis d992e14394 [libclang] Introduce a new function to apply the indexing callbacks on an existing
CXTranslationUnit, mainly to be used for indexing a PCH.

llvm-svn: 144623
2011-11-15 06:20:16 +00:00
Eli Friedman 95ff70021c Fix crash in calling convention code expanding an struct with a complex member.
llvm-svn: 144612
2011-11-15 02:46:03 +00:00
John McCall d5c98ae695 Resolve placeholder expressions before trying to deduce
'auto'.  Introduce a convenience method to make this a bit
easier, and use it elsewhere.

llvm-svn: 144605
2011-11-15 01:35:18 +00:00
Devang Patel 9957e8b789 Remove extra ';'.
llvm-svn: 144604
2011-11-15 01:30:40 +00:00
Nick Lewycky 5f2899cbfa The optimizers figured out how to make this store 6.
llvm-svn: 144597
2011-11-15 00:19:16 +00:00
Ted Kremenek ec9b50d961 Fix potential memory leak for clients of clang_getOverriddenCursors(). If the number of overriden cursors is 0, do not allocate an array of CXCursors. This fixes a memory leak in c-index-test, and clients who use this API in a similar way.
llvm-svn: 144595
2011-11-14 23:51:37 +00:00
Benjamin Kramer 02faa35477 A space in a diagnostic group is a bead idea.
llvm-svn: 144594
2011-11-14 23:44:04 +00:00
Benjamin Kramer 116d8879e6 Print a typo correction hint for unknown warning flags.
$ clang -Wololo t.c
warning: unknown warning option '-Wololo'; did you mean '-Wall'? [-Wunknown-warning-option]

llvm-svn: 144591
2011-11-14 23:30:34 +00:00
Matt Beaumont-Gay 8e9aae5999 Don't track depfiles as result files which need to be cleaned up on failure.
This is a partial revert of r143846. While cleaning up after a crash is
probably a good idea, we were also deleting .d files if the compilation failed
due to invalid input, which is not the desired behavior. The test is XFAIL'd
until the cleanup code can be reworked to do the right thing.

llvm-svn: 144590
2011-11-14 23:24:52 +00:00
Douglas Gregor 0201a4c2d3 When we're checking access in a dependent context, don't try to look
at the bases of an undefined class. Fixes <rdar://problem/10438657>.

llvm-svn: 144582
2011-11-14 23:00:43 +00:00
Argyrios Kyrtzidis 86acd72bd2 [libclang] Slight changes to the indexing API and bigger internal changes for it.
llvm-svn: 144577
2011-11-14 22:39:19 +00:00
Douglas Gregor 4123a86fae Use Sema::RequireCompleteType to check for the completeness of
Objective-C classes. This has two purposes: to consistently provide
"forward declaration here" notes when we hit an incomplete type, and
to give LLDB a chance to complete the type.

RequireCompleteType bits from Sean Callanan!

llvm-svn: 144573
2011-11-14 22:10:01 +00:00
Ted Kremenek 1fcdaa9c05 ARC: make assignment to 'self' within class methods illegal. Fixes <rdar://problem/10416568>.
llvm-svn: 144572
2011-11-14 21:59:25 +00:00
Ted Kremenek 8e7fbcc3e4 [static analyzer] Tweak RetainCountChecker's diagnostics to correctly indicate if a message was due to a property access. This can
potentially be refactored for other clients, and this is a regression from the refactoring of property acceses.

llvm-svn: 144571
2011-11-14 21:59:21 +00:00
Ted Kremenek 731607fab2 [analyzer;Regionstore] handle loads from StringLiteral elements for StringLiterals representing wide strings. Fixes PR 11294.
llvm-svn: 144563
2011-11-14 20:05:54 +00:00
John McCall 16de4d20e0 In ARC, don't reclaim objects of Class type.
llvm-svn: 144561
2011-11-14 19:53:16 +00:00
Richard Trieu 5d1aff049e Change the checks in the type aka printing. A confusing case where the string
of the first type is the same as the aka string of the second type, but both
types are different.  Update the logic to print an aka for the first type to
show that they are different.

llvm-svn: 144558
2011-11-14 19:39:25 +00:00
Ted Kremenek b39fcfaa19 [analyzer] teach AnalysisDeclContext::getSelfDecl() about blocks that capture the 'self' variable of the enclosing ObjC method decl. Fixes <rdar://problem/10380300>.
llvm-svn: 144556
2011-11-14 19:36:08 +00:00
Eric Christopher 04832b9210 Fixup comment.
llvm-svn: 144548
2011-11-14 18:55:02 +00:00
Argyrios Kyrtzidis 7d268c3b8b [PCH] Load the chained objc categories only after recursive loading is finished
otherwise we may crash.

llvm-svn: 144524
2011-11-14 07:07:59 +00:00
Nico Weber d60b72f696 Fix a regression in wide character codegen. See PR11369.
llvm-svn: 144521
2011-11-14 05:17:37 +00:00
Argyrios Kyrtzidis 846e61a363 [PCH] Do not crash if a class extension in a chained PCH introduces/redeclares a property.
llvm-svn: 144520
2011-11-14 04:52:29 +00:00
Argyrios Kyrtzidis 09c1b3d858 [PCH] In ASTWriter::WriteChainedObjCCategories use getDeclID since the decls
should have been already emitted.

llvm-svn: 144519
2011-11-14 04:52:24 +00:00
Argyrios Kyrtzidis 70480496c8 [libclang] Move the check for errors in c-index-test before the TU gets disposed.
llvm-svn: 144514
2011-11-13 23:39:14 +00:00
Argyrios Kyrtzidis f5ab0345fc [PCH] When chaining a PCH and serializing HeaderSearch, make sure the HeaderFileInfos
from the primary PCH is deserialized, otherwise we lose info that headers were
already #imported/#included.

llvm-svn: 144510
2011-11-13 22:08:39 +00:00
Argyrios Kyrtzidis e74e8222ee [libclang] for c-index-test, check for CINDEXTEST_FAILONERROR when doing -test-load-source-reparse
llvm-svn: 144509
2011-11-13 22:08:33 +00:00
Argyrios Kyrtzidis 95dfc12cd6 Don't crash when a duplicate interface/protocol is inside an extern "C" context.
llvm-svn: 144508
2011-11-13 22:08:30 +00:00
Rafael Espindola 6cfa82bc5f Fix the signature of the getcontext builtin. Patch by Dimitry Andric.
llvm-svn: 144505
2011-11-13 21:51:09 +00:00
Benjamin Kramer 1871ed3d79 Silence unused variable warning.
llvm-svn: 144500
2011-11-13 16:52:09 +00:00
Peter Collingbourne fcc764d140 When reference binding array rvalues, such as those created by compound
literals of array type, materialise a temporary.

llvm-svn: 144483
2011-11-13 00:51:30 +00:00
Richard Smith ce40ad677e Represent an APValue based on a Decl as that Decl, rather than a DeclRefExpr
or MemberExpr which refers to it. As a side-effect, MemberExprs which refer to
static member functions and static data members are now emitted as constant
expressions.

llvm-svn: 144468
2011-11-12 22:28:03 +00:00
Argyrios Kyrtzidis f9d0f4744e [PCH] Fix the test.
llvm-svn: 144467
2011-11-12 21:07:54 +00:00
Argyrios Kyrtzidis 0ca3a8b6ef Add a method in ASTMutationListener for the last use of Decl's [is/set]ChangedSinceDeserialization
and remove them.

llvm-svn: 144466
2011-11-12 21:07:52 +00:00
Argyrios Kyrtzidis b97a4025ff [PCH] When completing an objc forward reference, do not serialize the chain of its categories because
it is going to be rewritten (and the chain will be serialized again), otherwise we may form a cycle in its
categories list when deserializing.

Also introduce ASTMutationListener::CompletedObjCForwardRef to notify that a forward reference
was completed; using Decl's isChangedSinceDeserialization/setChangedSinceDeserialization
is bug inducing and kinda gross, we should phase it out.

Fixes infinite loop in rdar://10418538.

llvm-svn: 144465
2011-11-12 21:07:46 +00:00
David Blaikie 256ee1963d Remove unnecessary 'else's after 'return's.
llvm-svn: 144464
2011-11-12 20:54:14 +00:00
Eli Friedman 47133bed4a Add missing casts to AST.
llvm-svn: 144455
2011-11-12 03:56:23 +00:00
Argyrios Kyrtzidis 3e429e7cc4 [libclang] Further simplify the indexing API.
That stuff can be added later on if we need them.
Also add some const goodness.

llvm-svn: 144446
2011-11-12 02:16:30 +00:00
Douglas Gregor 0daa607f55 Tweak the module map file test slightly, by putting one of the headers
into a submodule. Submodules aren't actually supported anywhere else,
but we do parse them, so this verifies that we're at least seeing
through them properly.

llvm-svn: 144436
2011-11-12 00:24:49 +00:00
Douglas Gregor 80b6904baf Implement a minor optimization when loading module maps to satisfy a
module import: don't re-check for a loaded module unless we've
actually loaded a new module map file. Already-loaded module map files
aren't interesting.

llvm-svn: 144435
2011-11-12 00:22:19 +00:00
Douglas Gregor af28ec80a3 When searching for a module, speculatively load module maps to see if
the module is described in one of the module maps in a search path or
in a subdirectory off the search path that has the same name as the
module we're looking for.

llvm-svn: 144433
2011-11-12 00:05:07 +00:00
Eli Friedman b29c8d55b9 Make test compatible with ARM hosts.
llvm-svn: 144428
2011-11-11 23:36:04 +00:00
Douglas Gregor 88bdfb0ed9 Teach the search for modules to consider modules described by a module
map, so long as they have an umbrella header. This makes it possible
to introduce a module map + umbrella header for a given set of
headers, to turn it into a module.

There are two major deficiencies here: first, we don't go hunting for
module map files when we just see a module import (so we won't know
about the modules described therein). Second, we don't yet have a way
to build modules that don't have umbrella headers, or have incomplete
umbrella headers.

llvm-svn: 144424
2011-11-11 23:20:24 +00:00
Douglas Gregor 910c37c85e Fix some typos, grammar errors, etc. in cursor kind descriptions
llvm-svn: 144412
2011-11-11 22:35:18 +00:00
Douglas Gregor ab0c8a849a Wire up the mapping from header files mentioned in module maps over to
the corresponding (top-level) modules. This isn't actually useful yet,
because we don't yet have a way to build modules out of module maps.

llvm-svn: 144410
2011-11-11 22:18:48 +00:00
Douglas Gregor 5257fc63e7 Resolve the header files named in module map "header" and "umbrella"
declarations to actual files.

llvm-svn: 144408
2011-11-11 21:55:48 +00:00
Richard Smith 617940f166 Extend -Wno-bind-to-temporary-copy and -Wno-{unnamed,local}-type-template-args
to disable the corresponding -Wc++98-compat warnings in addition to the C++11
extension warnings, so that people already using these flags can switch to C++11
mode and turn on -Wc++98-compat.

llvm-svn: 144404
2011-11-11 19:29:23 +00:00
Douglas Gregor 3c267f7aa9 Rename SPECIAL_TYPE_jmp_buf and SPECIAL_TYPE_sigjmp_buf to follow the
convention of SPECIAL_TYPE*.

llvm-svn: 144403
2011-11-11 19:13:12 +00:00
Douglas Gregor 718292f260 Introduce basic support for parsing module map files.
Module map files provide a way to map between headers and modules, so
that we can layer a module system on top of existing headers without
changing those headers at all.

This commit introduces the module map file parser and the module map
that it generates, and wires up the module map file parser so that
we'll automatically find module map files as part of header
search. Note that we don't yet use the information stored in the
module map.

llvm-svn: 144402
2011-11-11 19:10:28 +00:00
Sean Callanan 45e1328f3f When importing an ObjCInterfaceDecl, ensure that
superclass information is imported before validating
it.  This fixes spurious "incompatible superclasses"
errors in LLDB.

llvm-svn: 144393
2011-11-11 17:39:52 +00:00
Ted Kremenek 70394cf76c Tweak CXLoadedDiagnosticSetImpl::makeString() to include an extra null character, and change the creation of the FixIT's string to again just rely on this string (instead of duplicating it when calling createCXString).
llvm-svn: 144389
2011-11-11 15:19:48 +00:00
Benjamin Kramer b9af5f6eff Silence compiler warning.
llvm-svn: 144386
2011-11-11 14:13:03 +00:00
Richard Smith 6804be5a2e Constant expression evalation: const_cast support.
llvm-svn: 144382
2011-11-11 08:28:03 +00:00
Bob Wilson 1a9ad0fbee Search for libstdc++.dylib in llvm-gcc's files on darwin10. rdar://10419079
llvm-svn: 144381
2011-11-11 07:47:04 +00:00
NAKAMURA Takumi e89c3bd004 libclang/CXLoadedDiagnostic.cpp: Work around not to miss the string terminator on fixit.
FixIts might be exposed as C string via clang_getCString(), though the zero terminator is not allocated in CXLoadedDiagnosticSetImpl::makeString.

llvm-svn: 144379
2011-11-11 07:27:33 +00:00
Richard Smith 3ba71043dc Don't recurse so deep in this test, pending APValue rework to further reduce the
stack pressure.

llvm-svn: 144378
2011-11-11 07:10:32 +00:00
Richard Smith 6049446c47 Reduce the constexpr stack pressure somewhat. Hopefully this will be enough to
please the buildbots.

llvm-svn: 144375
2011-11-11 05:48:57 +00:00
NAKAMURA Takumi a5a032025b test/Misc/serialized-diags.c: Tweak FileCheck expressions to be tolerant to DOSish output.
FIXME: For now, " = 0Parse Issueexpected ';' after expression{{XXX}}" would not be matched due to unexpected garbage{{XXX} on some hosts.
llvm-svn: 144374
2011-11-11 05:12:45 +00:00
Richard Smith e97cbd7b3a Constant expression evaluation: support for constexpr member functions. This
reinstates r144273; a combination of r144333's fix for NoOp rvalue-to-lvalue
casts and some corresponding changes here resolve the regression which that
caused.

This patch also adds support for some additional forms of member function call,
along with additional testing.

llvm-svn: 144369
2011-11-11 04:05:33 +00:00
Ted Kremenek e8ffd1d48d Place 'argument unused during compilation' under a -W flag. Fixes <rdar://problem/10403653>.
llvm-svn: 144365
2011-11-11 03:58:21 +00:00
John McCall 03318c1dcf Don't apply NRVO to over-aligned variables. The caller only
guarantees alignment up to the ABI alignment of the return type.

llvm-svn: 144364
2011-11-11 03:57:31 +00:00
John McCall f1a3c2aee1 Be sure to insulate block literals from any cleanups in their
enclosing full-expressions.  It is somewhat amazing that 
this hasn't come up as a problem before.

llvm-svn: 144362
2011-11-11 03:19:12 +00:00
Eli Friedman 7771c835cd Add Linux multiarch include directories for mips/mipsel. Patch from Simon Atanasyan.
llvm-svn: 144358
2011-11-11 03:05:19 +00:00
NAKAMURA Takumi aacef7ea3c include/clang-c/Index.h: Update CINDEX_LINKAGE on 6 decls. Corresponds to libclang.exports in r144343
llvm-svn: 144357
2011-11-11 02:51:09 +00:00
Eli Friedman 4f64e1819b Make sure that restrict-qualifying an array actually adds a restrict qualifier. PR11354. (operator bool() is evil!)
llvm-svn: 144355
2011-11-11 02:00:42 +00:00
Ted Kremenek a0e32fc8b6 [serialized diagnostics]: add test cases for serialized diagnostics, including a test case for no issues, multiple issues, and
a single issue.  Along the way, tweak c-index-test -read-diagnostics output so it is easier to tell what diagnostics are
child diagnostics.

llvm-svn: 144349
2011-11-11 00:46:43 +00:00
Douglas Gregor 197ac203af I predict that HeaderSearch will need the ability to generate
diagnostics in the future. Make it so.

llvm-svn: 144347
2011-11-11 00:35:06 +00:00
Argyrios Kyrtzidis 7519c5e440 [libclang] Simplify the indexing API.
Cut down the number of callbacks to more generic ones. Clients can check
an enum to find out what kind of declaration it is and they can call functions
to get more specific information than the generic provided info.

llvm-svn: 144343
2011-11-11 00:23:36 +00:00
Argyrios Kyrtzidis 85b075b845 Add a const version of ObjCClassDecl::getForwardDecl, no functionality change.
llvm-svn: 144342
2011-11-11 00:23:31 +00:00
Francois Pichet f707ae6733 Move "Unqualified lookup into dependent bases of class templates" Microsoft specific behavior from -fms-extensions to -fms-compatibility.
llvm-svn: 144341
2011-11-11 00:12:11 +00:00
Ted Kremenek 61fb647fb4 [static analyzer] be more specific when running removeDeadBindings. Instead of seeing if the predecessor node was a non-StmtPoint, check if it is specifically a BlockEntrance node.
llvm-svn: 144340
2011-11-11 00:10:55 +00:00
Ted Kremenek e73d9ed1a2 Add top-level driver option '--serialize-diagnostics' for serialize compiler diagnostics to a file.
llvm-svn: 144339
2011-11-11 00:07:43 +00:00
Richard Smith 4a905b6799 Implicit casts from rvalue to lvalue are not meaningful. Don't accidentally add
them when performing a const conversion on the implicit object argument for a
member operator call on an rvalue.

No change to the testsuite: the test for this change is that the added
assertion does not fire any more.

llvm-svn: 144333
2011-11-10 23:32:36 +00:00
Ted Kremenek 20be0b4397 [static analyzer]: only call RemoveDeadBindings() when analyzing non-Expr stmts, entering a basic block, or analyzing non-consumed expressions. This sigificantly speeds up analysis time, and reduces analysis time down to 27% less than before we linearized the CFG.
llvm-svn: 144332
2011-11-10 23:26:10 +00:00
Pete Cooper 9d6055133b Add invariant.load metadata to loads from selector references. Allows these loads to later be moved/combined in the optimizer. Fixes <rdar://problem/6027699>
llvm-svn: 144318
2011-11-10 21:45:06 +00:00
Eli Friedman 5ceb8aa23e Add missing dependency for shared library build to CMakeLists. Patch by Johannes Obermayr.
llvm-svn: 144310
2011-11-10 20:07:09 +00:00
Devang Patel 63104ad417 Revert r144273. It causes clang self-host build failure.
llvm-svn: 144296
2011-11-10 17:47:39 +00:00
Benjamin Kramer 931ee8e727 serialized diagnostics: simplify code.
llvm-svn: 144277
2011-11-10 11:29:20 +00:00