Commit Graph

34455 Commits

Author SHA1 Message Date
Douglas Gregor 73141fa98d Within the module representation, generalize the notion of an umbrella
header to also support umbrella directories. The umbrella directory
for an umbrella header is the directory in which the umbrella header
resides.

No functionality change yet, but it's coming.

llvm-svn: 146158
2011-12-08 17:39:04 +00:00
Douglas Gregor 2537a36483 Keep track of import dependencies between submodules within the module
that's currently being built. This is important for supporting
transitive dependencies ("export *" in the module map) completely.

llvm-svn: 146156
2011-12-08 17:01:29 +00:00
David Blaikie ecd8a94acf Decltype in non-pseudo (& non-dependent) dtor calls.
llvm-svn: 146155
2011-12-08 16:13:53 +00:00
Douglas Gregor ddaa69cb28 Convert paths to native format before constructing a
directory_iterator for them.

llvm-svn: 146154
2011-12-08 16:13:24 +00:00
Hans Wennborg 70a1324428 Only do typo correction for implicit function decls when
they are treated as errors.

Doing typo correction when these are just warnings slows down the
compilation of source which deliberately uses implicit function
declarations.

llvm-svn: 146153
2011-12-08 15:56:07 +00:00
Erik Verbruggen f988785dc0 Fix: allow @protocol forward declarations inside @implementation-s.
llvm-svn: 146147
2011-12-08 09:58:43 +00:00
Francois Pichet 311084734d Unbreak MSVC build.
llvm-svn: 146146
2011-12-08 09:32:22 +00:00
Francois Pichet 33786cb499 Remove unused parameter from the LateParsedTemplatedFunction constructor.
llvm-svn: 146145
2011-12-08 09:11:52 +00:00
Peter Collingbourne 266e3dda17 Add an experimental MallocSizeofChecker, which reports inconsistencies
between the casted type of the return value of a malloc/calloc/realloc
call and the operand of any sizeof expressions contained within
its argument(s).

llvm-svn: 146144
2011-12-08 08:31:14 +00:00
Hal Finkel 221e11e864 Allow clang to find gcc libs on suse ppc64
llvm-svn: 146142
2011-12-08 05:50:03 +00:00
Rafael Espindola 18c7920d6b Add a minimal unwind.h that knows how to forward to the system one in systems
that have it in /usr/include (only OS X Lion so far).

llvm-svn: 146140
2011-12-08 05:01:39 +00:00
David Blaikie 7491e73709 Use the real end of the decltype expression.
llvm-svn: 146138
2011-12-08 04:53:15 +00:00
Argyrios Kyrtzidis 831411f42b [libclang] When doing clang_findReferencesInFile, make sure we don't crash
if we come up against a null Decl.

No test case unfortunately. rdar://10457799.

llvm-svn: 146127
2011-12-08 01:56:07 +00:00
Bob Wilson 8c9052bd31 Minor cleanup. Avoid redundant getTriple() calls.
llvm-svn: 146122
2011-12-08 01:10:19 +00:00
Argyrios Kyrtzidis bf1d884d9e [libclang] Remove IndexingContext's getScopedContext(), it's not useful
now that client containers can be set via function calls.

llvm-svn: 146117
2011-12-08 00:54:07 +00:00
Daniel Dunbar 3ca41d4758 Driver/Linux: Fix the ASAN library path to match current compiler-rt
integration.

llvm-svn: 146098
2011-12-07 23:22:17 +00:00
Daniel Dunbar f4916cde76 Driver: Add a --rtlib={compiler-rt,libgcc} argument which I plan to use to allow
dual support for compiler-rt on Linux, during bringup.

llvm-svn: 146094
2011-12-07 23:03:15 +00:00
Douglas Gregor 9458f82df7 Implement inference for the "Private" submodule corresponding to
private headers in a framework.

llvm-svn: 146082
2011-12-07 22:05:21 +00:00
Douglas Gregor 8030677b70 Make sure we pick up module_private.map when loading a module.map file.
llvm-svn: 146074
2011-12-07 21:25:07 +00:00
Argyrios Kyrtzidis 663c8ecda1 [libclang] Indexing API: provide both the semantic and the lexical container.
They are generally the same except in C++ cases like out-of-line member functions.

llvm-svn: 146069
2011-12-07 20:44:19 +00:00
Argyrios Kyrtzidis b3c16bad20 [libclang] Fix indexing of C++ bases in a C++ class.
llvm-svn: 146068
2011-12-07 20:44:15 +00:00
Argyrios Kyrtzidis 520028802c [libclang] Introduce CXIdxEntityLanguage that indicates the language
of an indexed entity.

llvm-svn: 146067
2011-12-07 20:44:12 +00:00
Anna Zaks 9da86ce834 [analyzer] Cleanup: use the variable.
llvm-svn: 146056
2011-12-07 19:56:13 +00:00
Daniel Dunbar ba45b3faf4 runtime/Linux: Include the profile and ASAN libs on x86.
llvm-svn: 146051
2011-12-07 19:35:10 +00:00
Anna Zaks e87ad4625c [analyzer] More www; document ProgramState->dump().
llvm-svn: 146049
2011-12-07 19:04:27 +00:00
Anna Zaks db0e17336d [analyzer] Update the checker writer manual with explanation of SVals
and the link to checker callback documentation.

SVal, SymExpr, MemRegion description is a slightly edited version of
Ted's reply to a question on cfe-dev list.

llvm-svn: 146048
2011-12-07 19:04:24 +00:00
Benjamin Kramer 4d2b32ba51 Remove unused-but-set variable.
llvm-svn: 146034
2011-12-07 12:50:05 +00:00
Hans Wennborg 772e9270f6 Make printf warnings refer to intmax_t et al. by name
in addition to underlying type.

For example, the warning for printf("%zu", 42.0);
changes from "conversion specifies type 'unsigned long'" to "conversion
specifies type 'size_t' (aka 'unsigned long')"

(This is a second attempt after r145697, which got reverted.)

llvm-svn: 146032
2011-12-07 10:33:11 +00:00
Argyrios Kyrtzidis 7910d7b72a Make changes to SDiagsWriter to make it work in combination with the ARC migrator:
-Allow it to be used with multiple BeginSourceFile/EndSourceFile calls; for this introduce
 a "finish" callback method in the DiagnosticConsumer. SDiagsWriter finishes up the serialization
 file inside this method.
-Make it independent of any particular DiagnosticsEngine; make it use the SourceManager of the
 Diagnostic object.
-Ignore null source ranges.

llvm-svn: 146020
2011-12-07 05:52:12 +00:00
Argyrios Kyrtzidis 2b0b43cf56 [libclang] Index C++ namespaces.
llvm-svn: 146019
2011-12-07 05:52:06 +00:00
Eli Friedman 1f1e35e034 Fix multilib library paths on ppc64 Linux. Patch by Michael Kostylev. PR11472.
llvm-svn: 146016
2011-12-07 04:00:53 +00:00
Daniel Dunbar 2931cd9cf9 www: Update getting started to encourage people to check out compielr-rt.
llvm-svn: 146014
2011-12-07 03:04:42 +00:00
Nick Lewycky 7d04ad1b40 Initialize these values, fixing the build in cases where stack realignment
actually occurs.

llvm-svn: 146013
2011-12-07 02:33:23 +00:00
Douglas Gregor e7ab36693b Implement basic support for private headers in frameworks. In essence,
when we load a module map (module.map) from a directory, also load a
private module map (module_private.map) for that directory, if
present. That private module map can inject a new submodule that
captures private headers.

llvm-svn: 146012
2011-12-07 02:23:45 +00:00
Ted Kremenek 9c9e81085f Tweak serialized diagnostics to support errors with no categories. Fixes <rdar://problem/10538300>.
llvm-svn: 146011
2011-12-07 02:08:00 +00:00
Eli Friedman dae858aca3 Make sure we correctly zero-initialize unions containing a pointer to data member as the first field. PR11487.
llvm-svn: 146009
2011-12-07 01:30:11 +00:00
Anna Zaks b86fdbe7e3 [analyzer] Propagate taint through MemRegions.
SVal can be not only a symbol, but a MemRegion. Add support for such
cases.

llvm-svn: 146006
2011-12-07 01:09:52 +00:00
Douglas Gregor ee78d3e020 If we can't write the temporary module map file when compiling a
module, at least have the decency to complain about it.

llvm-svn: 146002
2011-12-07 00:54:14 +00:00
Richard Smith 42d3af9d95 When folding the size of a global scope VLA to a constant, require the array
bound to not have side effects(!). Add constant-folding support for expressions
of void type, to ensure that we can still fold ((void)0, 1) as an array bound.

llvm-svn: 146000
2011-12-07 00:43:50 +00:00
Fariborz Jahanian 6bdeb14d5d objc: issue deprecated/unavailable diagnostic when
methods with these attributes are sent to receivers
of 'id' type too. // rdar://10459930

llvm-svn: 145999
2011-12-07 00:30:00 +00:00
Richard Smith 1e1f5abf77 DeadStoresChecker: when whitelisting dead initializations with constants, look
for a foldable constant rather than an IR-level constant. This is still far too
liberal, but is a step in the right direction.

llvm-svn: 145990
2011-12-06 23:25:15 +00:00
Anna Zaks 52fb9c08fc [analyzer] Add comments related to symbol_iterator
llvm-svn: 145987
2011-12-06 23:12:38 +00:00
Anna Zaks ee1a43533b [analyzer] Refactor: Move symbol_iterator from SVal to SymExpr, use it
for finding dependent symbols for taint.

llvm-svn: 145986
2011-12-06 23:12:33 +00:00
Anna Zaks c25efccc8b [analyzer] Propagate taint through NonLoc to NonLoc casts.
- Created a new SymExpr type - SymbolCast.
 - SymbolCast is created when we don't know how to simplify a NonLoc to
NonLoc casts.
 - A bit of code refactoring: introduced dispatchCast to have better
code reuse, remove a goto.
 - Updated the test case to showcase the new taint flow.

llvm-svn: 145985
2011-12-06 23:12:27 +00:00
Anna Zaks 8629c0a4d0 [analyzer] Remove an unnecessary check.
llvm-svn: 145984
2011-12-06 23:12:17 +00:00
Douglas Gregor 2f554c4c1b Add a FIXME to provide a sensible error message here
llvm-svn: 145983
2011-12-06 23:04:08 +00:00
Richard Smith 161f09abd7 Move vector bitcast handling in constant expressions from the expression
evaluator into constant initializer handling / IRGen. The practical consequence
of this is that the bitcast now lives in the constant's definition, rather than
in its uses.

The code in the constant expression evaluator was producing vectors of the wrong
type and size (and possibly of the wrong value for a big-endian int-to-vector
bitcast). We were getting away with this only because we don't yet support
constant-folding of any expressions which inspect vector values.

llvm-svn: 145981
2011-12-06 22:44:34 +00:00
Douglas Gregor 19f9f7bc6d Use absolute paths for temporary module map files
llvm-svn: 145973
2011-12-06 22:05:29 +00:00
Argyrios Kyrtzidis 66f433a746 [libclang] API enhancements by Joe Groff!
- Exposes a CXType_Vector type kind for vector types.
- Adds generalized versions of the clang_getArrayElementType and clang_getArraySize functions, named clang_getElementType and clang_getNumElements, which work on array, vector, or complex types.
- Adds additional functions for querying function types. clang_isFunctionTypeVariadic returns true if a function type is variadic. clang_getFunctionCallingConv returns an enumeration value indicating the calling convention of the function type. clang_getNumArgTypes returns the number of static argument types, and clang_getArgType gets the type of an argument.
- Adds a clang_getTypedefDeclUnderlyingType function to get the underlying type from a TypedefDecl cursor.
- Adds a clang_getEnumDeclIntegerType function to get the integer type from an EnumDecl cursor.
- Adds clang_getEnumConstantDeclValue and clang_getEnumConstantDeclUnsignedValue functions to get the value of an EnumConstantDecl as a signed or unsigned long long, respectively.
- Exposes a CXCursor_AsmLabelAttr cursor kind for __asm__("label") attributes.
- Alters clang_getCursorSpelling to return the label value for AsmLabelAttr-kind cursors.

llvm-svn: 145972
2011-12-06 22:05:01 +00:00
Douglas Gregor 158764bbe2 Rename Objective-C-only tests to .m
llvm-svn: 145959
2011-12-06 20:51:42 +00:00
Douglas Gregor d6343c99d6 Remove misleading error message
llvm-svn: 145958
2011-12-06 19:57:48 +00:00
Douglas Gregor e89dbc1d98 When inferring a module map for a framework, infer subframework
modules for each of its subframeworks.

llvm-svn: 145957
2011-12-06 19:39:29 +00:00
Benjamin Kramer 1594618c39 Remove unused member to appease valgrind.
llvm-svn: 145956
2011-12-06 19:26:57 +00:00
Kostya Serebryany 0b692ce7ca [asan] Mac: do not link dynamic libs with the asan-rt, use -undefined dynamic_lookup for dynamic libs. Style fixes. Patch by glider@google.com
llvm-svn: 145955
2011-12-06 19:18:44 +00:00
Douglas Gregor dd005f69f0 Allow inferred submodules for any (sub)module that has an umbrella header
llvm-svn: 145945
2011-12-06 17:34:58 +00:00
Douglas Gregor 356f3d4b53 When suggesting a module import for a #include or #import, suggest the
most specific (sub)module based on the actual file we find, rather
than always importing the top-level module. This means
that #include'ing <Foo/Blah.h> should give us the submodule Foo.Blah.

llvm-svn: 145942
2011-12-06 17:31:28 +00:00
Douglas Gregor f2161a70aa Implement modules support for subframeworks (aka embedded
frameworks). A submodule can now be labeled as a "framework", and
header search will look into the appropriate Headers/PrivateHeaders
subdirectories for named headers.

llvm-svn: 145941
2011-12-06 17:16:41 +00:00
Douglas Gregor e5626c4119 When building the main file to parse given a module map, don't skip
explicit submodules or umbrella headers from submodules. Instead,
build the entire module at once, and let the name-hiding mechanisms
hide the contents of explicit submodules at load time.

llvm-svn: 145940
2011-12-06 17:15:11 +00:00
Daniel Dunbar e946e361ab Headers: wmmintrin.h only needs xmmintrin.h.
- Fixes <rdar://problem/10261246> clang -maes option is not sufficient to
   include <wmmintrin.h>

llvm-svn: 145939
2011-12-06 16:17:54 +00:00
Douglas Gregor 930a85cc2d Minor tweak to prepare for submodules with umbrella headers. No actual
functionality change yet.

llvm-svn: 145938
2011-12-06 16:17:15 +00:00
Rafael Espindola 488ea473db Install cpuid.h when building with cmake too.
llvm-svn: 145935
2011-12-06 15:46:47 +00:00
Hans Wennborg 2fb8b91f6f Suggest typo corrections for implicit function declarations.
A mistyped function call becomes an inmplicit function declaration in C.
Suggest typo correction when one can be found.

llvm-svn: 145930
2011-12-06 09:46:12 +00:00
Erik Verbruggen c6c8d9356d Extend warnings for missing '@end'.
Fixes PR2709.

llvm-svn: 145928
2011-12-06 09:25:23 +00:00
Richard Trieu 5f623229ec Switch a cast to a dyn_cast and check the pointer before using. Fixes a crash
in the following code:

void test4(bool (&x)(void)) {
  while (x);
}

llvm-svn: 145918
2011-12-06 04:48:01 +00:00
Nick Lewycky 32275b9739 Fix test for unrelated changes.
llvm-svn: 145915
2011-12-06 03:46:28 +00:00
Nick Lewycky f4d3f7a0b9 Stack realignment is a tristate. Add -mno-stackrealign to turn off all stack
realignment, even with locals with alignment exceeding the ABI guarantee.

llvm-svn: 145909
2011-12-06 03:33:03 +00:00
Eli Friedman b8e45b28da Minor comment update.
llvm-svn: 145905
2011-12-06 03:08:26 +00:00
John McCall e5e1b88bbc Fix an extremely stupid bug causing terrible miscompilations
of &= on pseudo-objects.

llvm-svn: 145904
2011-12-06 02:56:18 +00:00
Douglas Gregor a89c5ac4a6 Implement inferred submodules support, which (when requested)
implicitly generates submodules corresponding to the headers that fall
within a module.

llvm-svn: 145887
2011-12-06 01:10:29 +00:00
Eli Friedman 7c6515a653 Make sure we perform lvalue-to-rvalue conversions for enum initializers. PR11484.
llvm-svn: 145874
2011-12-06 00:10:34 +00:00
Fariborz Jahanian 56f326e7f2 objc: put out more coherent warning when method definition
attributes don't match its declaration. // rdar://10529259.

llvm-svn: 145872
2011-12-06 00:02:41 +00:00
Joerg Sonnenberger db66ed0e4c Add -mstack-alignment=X and fix -mstackrealign handling now that the
backend options are gone.

llvm-svn: 145868
2011-12-05 23:05:23 +00:00
Fariborz Jahanian 7b1866930e More refactoring of objc rewriter.
llvm-svn: 145867
2011-12-05 22:59:54 +00:00
Douglas Gregor 734410916a Parse inferred submodules in module maps, track their contents in
Module, and (de-)serialize this information. Semantics of inferred
submodules to follow.

llvm-svn: 145864
2011-12-05 22:27:44 +00:00
Eli Friedman 6d694a38fd Make EmitAggregateCopy take an alignment argument. Make EmitFinalDestCopy pass in the correct alignment when known.
The test includes a FIXME for a related case involving calls; it's a bit more complicated to fix because the RValue class doesn't keep track of alignment.

<rdar://problem/10463337>
  

llvm-svn: 145862
2011-12-05 22:23:28 +00:00
Argyrios Kyrtzidis 1a10f29b2f [libclang] When indexing a field in a C++ class, return an entity
of kind CXIdxEntity_CXXInstanceVariable. rdar://10522503.

llvm-svn: 145859
2011-12-05 22:05:28 +00:00
Anna Zaks 02a1fc1da6 [analyzer] Rely on LLVM Dominators in Clang dominator computation.
(Previously, Clang used it's implementation of dominators.)

The patch is contributed by Guoping Long!

llvm-svn: 145858
2011-12-05 21:33:11 +00:00
Anna Zaks 5c10794254 [analyzer] Mark ConstraintManager::canReasonAbout as protected.
llvm-svn: 145857
2011-12-05 21:33:06 +00:00
Anna Zaks 2d2999821b [analyzer] Simplify the condition.
This is a fixup for r145832.

The extra clauses do not matter after we remove the dependency on canReasonAbout(InitVal) in r145832.

llvm-svn: 145856
2011-12-05 21:33:01 +00:00
Anna Zaks d624f60a89 [analyzer] Simplify the expected-warning statement.
llvm-svn: 145855
2011-12-05 21:32:58 +00:00
Lang Hames df5c121f8e Add a warning for implicit conversion from function literals (and static
methods) to bool. E.g.

void foo() {}
if (f) { ... // <- Warns here.
}

Only applies to non-weak functions, and does not apply if the function address
is taken explicitly with the addr-of operator.

llvm-svn: 145849
2011-12-05 20:49:50 +00:00
Lang Hames d42bb47782 Make isWeakDecl available as a method on ValueDecl.
llvm-svn: 145845
2011-12-05 20:16:26 +00:00
Fariborz Jahanian 8efef60f69 More objc rewriter refactoring.
llvm-svn: 145841
2011-12-05 19:50:04 +00:00
Anna Zaks 004695b56e [analyzer] Add a missing taint tester warning.
llvm-svn: 145834
2011-12-05 18:58:33 +00:00
Anna Zaks d066f79c80 [analyzer] Unify SymbolVal and SymExprVal under a single SymbolVal
class.

We are going into the direction of handling SymbolData and other SymExpr
uniformly, so it makes less sense to keep two different SVal classes.
For example, the checkers would have to take an extra step to reason
about each type separately.

The classes have the same members, we were just using the SVal kind
field for easy differentiation in 3 switch statements. The switch
statements look more ugly now, but we can make the code more readable in
other ways, for example, moving some code into separate functions.

llvm-svn: 145833
2011-12-05 18:58:30 +00:00
Anna Zaks a636fbe73f [analyzer] Remove all uses of ConstraintManager::canResonAbout() from
ExprEngine.

Teach SimpleConstraintManager::assumeSymRel() to propagate constraints
to symbolic expressions.

+ One extra warning (real bug) is now generated due to enhanced
assumeSymRel().

llvm-svn: 145832
2011-12-05 18:58:25 +00:00
Anna Zaks 51090d5f7f [analyzer] First step toward removing
ConstraintManager::canReasonAbout() from the ExprEngine.

ExprEngine should not care if the constraint solver can reason about
something or not. The solver should be able to handle all the SymExprs.

To do this, the solver should be able to keep track of not only the
SymbolData but of all SymExprs. This is why we change SymbolRef to be an
alias of SymExpr*. When encountering an expression it cannot simplify,
the solver should just add the constraints to it.

llvm-svn: 145831
2011-12-05 18:58:19 +00:00
Anna Zaks 820e87e928 [analyzer] Minor improvements on RangeConstraint pretty-printing.
llvm-svn: 145830
2011-12-05 18:58:14 +00:00
Anna Zaks 223516523e [analyzer] Change RetainCountChecker to use symbol dump method instead
of relying on SymbolID.

This way any expression can be printed (not only SymbolData).

llvm-svn: 145829
2011-12-05 18:58:11 +00:00
Anna Zaks f784d08d25 [analyzer] Add ability to do a simple ProgramState dump() without
requiring CFG.

Adding more ugly code; the evnvironment printing should be moved to
envirnment at some point.

llvm-svn: 145828
2011-12-05 18:58:08 +00:00
Anna Zaks 1c215d0a11 [analyzer] Add a debug checker to test for tainted data.
llvm-svn: 145827
2011-12-05 18:58:01 +00:00
Fariborz Jahanian 68e628e51f Some early refactoring of objective-c rewriter.
llvm-svn: 145824
2011-12-05 18:43:13 +00:00
Kostya Serebryany 4dd9e4765d [asan] don't require libstdc++ for asan on linux. Mac fix will go separately
llvm-svn: 145823
2011-12-05 18:32:37 +00:00
Chris Lattner 1e13e8ac97 we got badgered into supporting multi-alternative constraints.
llvm-svn: 145822
2011-12-05 18:29:03 +00:00
Douglas Gregor d8bd7537ec Inferred framework modules automatically export anything they import
(i.e., 'export *'), to better match the semantics of headers.

llvm-svn: 145813
2011-12-05 17:40:25 +00:00
Douglas Gregor 8c7c83522b Fix printing of wildcard exports.
llvm-svn: 145812
2011-12-05 17:34:59 +00:00
Douglas Gregor f5eedd05db Implement support for wildcard exports in modules, allowing a module
to re-export anything that it imports. This opt-in feature makes a
module behave more like a header, because it can be used to re-export
the transitive closure of a (sub)module's dependencies.

llvm-svn: 145811
2011-12-05 17:28:06 +00:00
Douglas Gregor 603825163f Actually add a useful bit to the comment pre-FIXME
llvm-svn: 145809
2011-12-05 16:35:23 +00:00
Douglas Gregor 0093b3c7bf When writing a module file, keep track of the set of (sub)modules that
it imports, establishing dependencies at the (sub)module
granularity. This is not a user-visible change (yet).

llvm-svn: 145808
2011-12-05 16:33:54 +00:00
NAKAMURA Takumi 770142e49f include/clang*/Makefile: Tweak installation to work with CLANG_SRCDIR.
llvm-svn: 145800
2011-12-05 06:13:20 +00:00