Anna Zaks [Tue, 6 Dec 2011 23:12:27 +0000 (23:12 +0000)]
[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.
Richard Smith [Tue, 6 Dec 2011 22:44:34 +0000 (22:44 +0000)]
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.
- 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.
Douglas Gregor [Tue, 6 Dec 2011 17:31:28 +0000 (17:31 +0000)]
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.
Douglas Gregor [Tue, 6 Dec 2011 17:16:41 +0000 (17:16 +0000)]
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.
Douglas Gregor [Tue, 6 Dec 2011 17:15:11 +0000 (17:15 +0000)]
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.
Douglas Gregor [Mon, 5 Dec 2011 22:27:44 +0000 (22:27 +0000)]
Parse inferred submodules in module maps, track their contents in
Module, and (de-)serialize this information. Semantics of inferred
submodules to follow.
Eli Friedman [Mon, 5 Dec 2011 22:23:28 +0000 (22:23 +0000)]
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.
Anna Zaks [Mon, 5 Dec 2011 18:58:30 +0000 (18:58 +0000)]
[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.
Anna Zaks [Mon, 5 Dec 2011 18:58:19 +0000 (18:58 +0000)]
[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.
Douglas Gregor [Mon, 5 Dec 2011 17:28:06 +0000 (17:28 +0000)]
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.
Douglas Gregor [Mon, 5 Dec 2011 16:33:54 +0000 (16:33 +0000)]
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).
If block literal return type is not specified, return type of the block is
inferred from return types. All the return statements have to agree about the type.
// rdar://10466373
Francois Pichet [Sat, 3 Dec 2011 15:55:29 +0000 (15:55 +0000)]
In Microsoft mode, don't perform typo correction in a template member function dependent context because it interferes with the "lookup into dependent bases of class templates" feature.
Basically typo correction will try to offer a correction instead of looking into type dependent base classes.
I found this problem while parsing Microsoft ATL code with clang.
[PCH] Make sure that the SourceExpr of a OpaqueValueExpr is always initialized
when deserialized, fixing random crashes in libclang.
Also simplifies how OpaqueValueExprs are [de]serialized.
The reader/writer automatically retains pointer equality of sub-statements (when a
statement node is referenced in multiple nodes), so no need to manually handle it.
Douglas Gregor [Sat, 3 Dec 2011 01:15:29 +0000 (01:15 +0000)]
Module files representing actual modules don't need to know the set of modules they import, since that information isn't actually used. Drop it from the AST file
Douglas Gregor [Sat, 3 Dec 2011 00:59:55 +0000 (00:59 +0000)]
Implement support for precompiled headers, preambles, and serialized
"main" files that import modules. When loading any of these kinds of
AST files, we make the modules that were imported visible into the
translation unit that loaded the PCH file or preamble.
Douglas Gregor [Sat, 3 Dec 2011 00:30:27 +0000 (00:30 +0000)]
Keep track of all of the import declarations that are parsed or
implicitly generated in a translation unit. Modules will need this
information to identify the actual imports that occurred.
Douglas Gregor [Fri, 2 Dec 2011 21:56:05 +0000 (21:56 +0000)]
Only perform checking of the predefines buffer when loading a
precompiled header. Previously, we were trying to gather predefines
buffers from all kinds of AST files (which doesn't make sense) and
were performing some validation when AST files were loaded as main
files.
With these tweaks, using PCH files that import modules no longer fails
immediately (due to mismatched predefines buffers). However, module
visibility is lost, so this feature does not yet work.
Hans Wennborg [Fri, 2 Dec 2011 19:22:15 +0000 (19:22 +0000)]
Make conversion specifier warning refer to typedef if possible.
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')"
Douglas Gregor [Fri, 2 Dec 2011 19:11:09 +0000 (19:11 +0000)]
When making a module visible, also make any of its exported modules
visible, allowing one to create modules that import (and then
re-export) other modules.
Douglas Gregor [Fri, 2 Dec 2011 17:30:13 +0000 (17:30 +0000)]
Notify the AST writer (via ASTDeserializationListener) when a
(sub)module is read from an AST file. This makes sure that the AST
writer knows how to map all modules to their global IDs.
Douglas Gregor [Fri, 2 Dec 2011 15:45:10 +0000 (15:45 +0000)]
Implement name hiding for macro definitions within modules, such that
only the macro definitions from visible (sub)modules will actually be
visible. This provides the same behavior for macros that r145640
provided for declarations.
Daniel Dunbar [Fri, 2 Dec 2011 02:31:32 +0000 (02:31 +0000)]
runtime/Linux: Initial support for tying compiler-rt build into Clang build on
Linux.
- Currently just builds a full library, and only on x86, and only for the
target arch.
Add support for AVX registers to clang inline asm. Add a small testcase
and update the Sema testcase with a register that we won't hit for a while
I hope.
Douglas Gregor [Fri, 2 Dec 2011 01:47:07 +0000 (01:47 +0000)]
Implementing parsing and resolution of module export declarations
within module maps, which will (eventually) be used to re-export a
module from another module. There are still some pieces missing,
however.
Richard Smith [Fri, 2 Dec 2011 00:30:33 +0000 (00:30 +0000)]
Fix wrong-code bug when a const automatic variable of struct type has both a
mutable member and a constant initializer. We'd previously promoted such
variables to global constants, resulting in nasal demons if the mutable member
was modified.
This is only a temporary fix. The subtle interplay between isConstantInitializer
and CGExprConstant is very bug-prone; there are some other issues in this area
which I will be addressing in subsequent, more major reworking of this code.
Eli Friedman [Fri, 2 Dec 2011 00:11:43 +0000 (00:11 +0000)]
When we're passing a vector with an illegal type through memory on x86-64, use byval so we're sure the backend does the right thing. Fixes va_arg with illegal vectors and an obscure ABI mismatch with __m64 vectors.