Commit Graph

2354 Commits

Author SHA1 Message Date
NAKAMURA Takumi eb3f454a67 lib/Frontend/InitHeaderSearch.cpp: [Cygwin] Add 4.5.3.
llvm-svn: 148637
2012-01-21 14:46:07 +00:00
NAKAMURA Takumi 44193b732e [Cygwin] Abandon Cygwin-1.5 and g++-3. Use g++-4.3 and higher on Cygwin-1.7.
llvm-svn: 148636
2012-01-21 14:46:01 +00:00
David Blaikie e4d798f078 More dead code removal (using -Wunreachable-code)
llvm-svn: 148577
2012-01-20 21:50:17 +00:00
Douglas Gregor 32fbe31246 Extract the (InputKind, std::string) pair used to describe inputs to
the front end into its own class, FrontendInputFile, to make it easier
to introduce new per-input data. No functionality change.

llvm-svn: 148546
2012-01-20 16:28:04 +00:00
Anna Zaks 1bea4bf590 Refactor: Pull getImmediateMacroName() out of DiagnosticRenderer and
into Lexer and Preprocessor; making it widely available.

llvm-svn: 148410
2012-01-18 20:17:16 +00:00
Argyrios Kyrtzidis da6e05476d [libclang] Make sure Preprocessor is set in ASTUnit during indexing.
llvm-svn: 148319
2012-01-17 18:48:07 +00:00
Hans Wennborg 507b567707 Treat -Wformat=0 as an alias for -Wformat.
Fixes PR9195.

llvm-svn: 148300
2012-01-17 09:30:38 +00:00
David Blaikie f47fa304a4 Remove unnecessary default cases in switches over enums.
This allows -Wswitch-enum to find switches that need updating when these enums are modified.

llvm-svn: 148281
2012-01-17 02:30:50 +00:00
David Chisnall fa35df628a Some improvements to the handling of C11 atomic types:
- Add atomic-to/from-nonatomic cast types
- Emit atomic operations for arithmetic on atomic types
- Emit non-atomic stores for initialisation of atomic types, but atomic stores and loads for every other store / load
- Add a __atomic_init() intrinsic which does a non-atomic store to an _Atomic() type.  This is needed for the corresponding C11 stdatomic.h function.
- Enables the relevant __has_feature() checks.  The feature isn't 100% complete yet, but it's done enough that we want people testing it.

Still to do:

- Make the arithmetic operations on atomic types (e.g. Atomic(int) foo = 1; foo++;) use the correct LLVM intrinsic if one exists, not a loop with a cmpxchg.
- Add a signal fence builtin
- Properly set the fenv state in atomic operations on floating point values
- Correctly handle things like _Atomic(_Complex double) which are too large for an atomic cmpxchg on some platforms (this requires working out what 'correctly' means in this context)
- Fix the many remaining corner cases

llvm-svn: 148242
2012-01-16 17:27:18 +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
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
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
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
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
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
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 1fb5c3a63a Implement support for module requirements, which indicate the language
features needed for a particular module to be available. This allows
mixed-language modules, where certain headers only work under some
language variants (e.g., in C++, std.tuple might only be available in
C++11 mode).

llvm-svn: 147387
2011-12-31 04:05:44 +00:00
Benjamin Kramer cf5014771d Add a target hook for FLT_EVAL_METHOD and use it to set the value on x86 with sse disabled.
x87 math evaluates everything with 80 bits precision, so we have to set FLT_EVAL_METHOD
to "2".

llvm-svn: 147311
2011-12-28 15:47:06 +00:00
Douglas Gregor deafd0b2a4 Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDecl
covers both declarations (@class) and definitions (@interface) of an
Objective-C class.

llvm-svn: 147299
2011-12-27 22:43:10 +00:00
Rafael Espindola 65e025cad5 Remove unused variables.
llvm-svn: 147260
2011-12-25 01:18:52 +00:00
Benjamin Kramer 3c6982b911 Give C11's __STDC_VERSION__ the final value.
llvm-svn: 147222
2011-12-23 17:00:41 +00:00
Benjamin Kramer e56f393249 Mass rename C1x references to C11. The name hasn't proliferated like "C++0x" so this patch is surprisingly small.
Also drop -Wc1x-extensions in favor of -Wc11-extensions. I don't think we need to keep this around for compatibility.

llvm-svn: 147221
2011-12-23 17:00:35 +00:00
Dylan Noblesmith e99b27f35e Let CompilerInvocation initialization indicate failure
This fixes the FIXMEs in ParseAnalyzeArgs. (Also a
precursor to moving the analyzer into an AST plugin.)

For consistency, do the same with AssemblerInvocation.

llvm-svn: 147218
2011-12-23 03:05:38 +00:00
Dylan Noblesmith 1ced737ebf remove unneeded config.h includes
llvm-svn: 147195
2011-12-22 22:49:47 +00:00
Chandler Carruth 1c032e0dc0 Update the CMake build for r146959's new files.
llvm-svn: 146967
2011-12-20 08:42:15 +00:00
David Blaikie 68e081d606 Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch
llvm-svn: 146959
2011-12-20 02:48:34 +00:00
Douglas Gregor 98a52db80c Detect when mapping a #include/#import over to a submodule ends up
hitting a submodule that was never actually created, e.g., because
that header wasn't parsed. In such cases, complain (because the
module's umbrella headers don't cover everything) and fall back to
including the header.

Later, we'll add a warning at module-build time to catch all such
cases. However, this fallback is important to eliminate assertions in
the ASTWriter when this happens.

llvm-svn: 146933
2011-12-20 00:28:52 +00:00
NAKAMURA Takumi 7bfba2f0d3 Frontend/VerifyDiagnosticConsumer.cpp: Fix an expression that had side-effect.
It had been causing test "Misc/diag-verify.cpp" failure on ms cl.exe. The emission was ordered unexpectedly as below;

First)  error: 'error' diagnostics seen but not expected:
Second) error: 'error' diagnostics expected but not seen:

llvm-svn: 146830
2011-12-17 13:00:31 +00:00
Ted Kremenek 4548e04458 Refactor SerializeDiagnosticsPrinter to using DiagnosticRenderer. This gives us comparative diagnostics
to TextDiagnosticPrinter.

This certainly can be cleaned up a bit.

llvm-svn: 146820
2011-12-17 05:26:11 +00:00
Ted Kremenek c4bbd8531e Refactor 'TextDiagnostic' to have a parent class 'DiagnosticRenderer' which handles
the policy of how diagnostics are lowered/rendered, while TextDiagnostic handles
the actual pretty-printing.

This is a first part of reworking SerializedDiagnosticPrinter to use the same
inclusion-stack/macro-expansion logic as TextDiagnostic.

llvm-svn: 146819
2011-12-17 05:26:04 +00:00
Richard Smith f6f003af6a C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit
argument to driver and frontend, to control the maximum number of notes so
produced (default 10). Fix APValue printing to be able to pretty-print all
APValue types, and move the testing for this functionality from a unittest to
a -verify test now that it's visible in clang's output.

llvm-svn: 146749
2011-12-16 19:06:07 +00:00
Anna Zaks cf2f8aab62 Fixup to the relaxed diagnostic verification option r146633.
We should exit when matching the '+' even if nothing was found to
prevent searching for all UNIT_MAX items.

llvm-svn: 146747
2011-12-16 18:28:45 +00:00
Argyrios Kyrtzidis a0caa29d6f Revert r146646 that was a mistake, and make the intended change in the right file.
Log:
[libclang] Try to unbreak mingw build.

llvm-svn: 146647
2011-12-15 05:53:37 +00:00
Argyrios Kyrtzidis d99472f4cd [libclang] Try to unbreak mingw build.
llvm-svn: 146646
2011-12-15 05:48:43 +00:00
Eli Friedman a109e92a66 <climits> has UINT_MAX, not <limits>.
llvm-svn: 146638
2011-12-15 04:24:37 +00:00
Anna Zaks f8548b080d Another fixit for r146633 (to make debian-fnt bot happy), try including limits instead.
llvm-svn: 146637
2011-12-15 03:27:51 +00:00
Anna Zaks 2c74eedbba Fixit for r146633. Make sure UINT_MAX is defined on all platforms.
(Attempt to turn debian-fnt buildbot back to green.)

llvm-svn: 146635
2011-12-15 02:58:00 +00:00
Anna Zaks a2510070ee Add support for matching one or more (aka regex +) diagnostic messages with -verify.
Ex:
// expected-warning + {{tainted}

llvm-svn: 146633
2011-12-15 02:28:16 +00:00
Richard Trieu 553b2b2e5d Modify how the -verify flag works. Currently, the verification string and
diagnostic message are compared.  If either is a substring of the other, then
no error is given.  This gives rise to an unexpected case:

  // expect-error{{candidate function has different number of parameters}}

will match the following error messages from Clang:

  candidate function has different number of parameters (expected 1 but has 2)
  candidate function has different number of parameters

It will also match these other error messages:

  candidate function
  function has different number of parameters
  number of parameters

This patch will change so that the verification string must be a substring of
the diagnostic message before accepting.  Also, all the failing tests from this
change have been corrected.  Some stats from this cleanup:

87 - removed extra spaces around verification strings
70 - wording updates to diagnostics
40 - extra leading or trailing characters (typos, unmatched parens or quotes)
35 - diagnostic level was included (error:, warning:, or note:)
18 - flag name put in the warning (-Wprotocol)

llvm-svn: 146619
2011-12-15 00:38:15 +00:00
Chad Rosier 1332d9b26a Per discussion on the list, remove BitcodeVerify pass to reimplement as a free function.
llvm-svn: 146530
2011-12-14 00:29:23 +00:00
Chad Rosier c4399f779b Add frontend flags to enable bitcode verifier pass.
llvm-svn: 146441
2011-12-12 23:05:47 +00:00
Tony Linthicum 76329bf83f Hexagon backend support
llvm-svn: 146413
2011-12-12 21:14:55 +00:00
Douglas Gregor c1aaf8cacb When we have an umbrella directory in a module map, recursively walk
the subdirectories to find headers in submodules.

llvm-svn: 146398
2011-12-12 19:13:53 +00:00
Daniel Dunbar 19939cc380 Driver: Handle -f{no-}honor-infinities, -f{no-}honor-nans, and
-ffinite-math-only.
 - No test case yet, I don't know how to construct a situation where this
   matters.

llvm-svn: 146297
2011-12-09 23:41:18 +00:00
Chandler Carruth f887db09e8 Move ChainedIncludesSource into the Frontend library. This never really
belonged in the Serialization library, it's setting up a compilation,
not just deserializing.

This should fix PR11512, making Serialization actually be layered below
Frontend, a long standing layering violation in Clang.

llvm-svn: 146233
2011-12-09 01:55:54 +00:00
Chandler Carruth b0ffe50da8 Move a free function from the Frontend library into the Lex library as
part of HeaderSearch. This function just normalizes filenames for use
inside of a synthetic include directive, but it is used in both the
Frontend and Serialization libraries so it needs a common home.

llvm-svn: 146227
2011-12-09 01:33:57 +00:00
Douglas Gregor 524e33e1f8 Implement umbrella directories for modules, which are similar to
umbrella headers in the sense that all of the headers within that
directory (and eventually its subdirectories) are considered to be
part of the module with that umbrella directory. However, unlike
umbrella headers, which are expected to include all of the headers
within their subdirectories, Clang will automatically include all of
the headers it finds in the named subdirectory.

The intent here is to allow a module map to trivially turn a
subdirectory into a module, where the module's structure can mimic the
directory structure.

llvm-svn: 146165
2011-12-08 19:11:24 +00:00
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
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
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
Douglas Gregor 2f554c4c1b Add a FIXME to provide a sensible error message here
llvm-svn: 145983
2011-12-06 23:04:08 +00:00
Douglas Gregor 19f9f7bc6d Use absolute paths for temporary module map files
llvm-svn: 145973
2011-12-06 22:05:29 +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
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
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
Douglas Gregor bcfc7d0229 When we treat an #include or #import as a module import, create an
implicit ImportDecl in the translation unit to record the presence of
the import.

llvm-svn: 145727
2011-12-02 23:42:12 +00:00
Douglas Gregor ff2be53f8f Introduce the notion of name visibility into modules. For a given
(sub)module, all of the names may be hidden, just the macro names may
be exposed (for example, after the preprocessor has seen the import of
the module but the parser has not), or all of the names may be
exposed. Importing a module makes its names, and the names in any of
its non-explicit submodules, visible to name lookup (transitively).

This commit only introduces the notion of name visible and marks
modules and submodules as visible when they are imported. The actual
name-hiding logic in the AST reader will follow (along with test cases).

llvm-svn: 145586
2011-12-01 17:11:21 +00:00
Douglas Gregor de3ef502a9 Promote ModuleMap::Module to a namespace-scope class in the Basic
library, since modules cut across all of the libraries. Rename
serialization::Module to serialization::ModuleFile to side-step the
annoying naming conflict. Prune a bunch of ModuleMap.h includes that
are no longer needed (most files only needed the Module type).

llvm-svn: 145538
2011-11-30 23:21:26 +00:00
Matt Beaumont-Gay eb44edad6d Don't collide loop variable names (to appease GCC)
llvm-svn: 145515
2011-11-30 19:41:21 +00:00
Douglas Gregor 6902197407 Implement (de-)serialization of the description of a module and its
submodules. This information will eventually be used for name hiding
when dealing with submodules. For now, we only use it to ensure that
the module "key" returned when loading a module will always be a
module (rather than occasionally being a FileEntry).

llvm-svn: 145497
2011-11-30 17:33:56 +00:00
Douglas Gregor f7a700fd01 When writing a module file, pass the module through to the AST
writer. No functionality change.

llvm-svn: 145479
2011-11-30 04:39:39 +00:00
Douglas Gregor 1805b8a42f Teach the preprocessor how to handle module import declarations that
involve submodules (e.g., importing std.vector), rather than always
importing the top-level module.

llvm-svn: 145478
2011-11-30 04:26:53 +00:00
Douglas Gregor 5196bc6b39 When loading a module that involves submodules (e.g., std.vector),
check whether the named submodules themselves are actually
valid, and drill down to the named submodule (although we don't do
anything with it yet). Perform typo correction on the submodule names
when possible.

llvm-svn: 145477
2011-11-30 04:03:44 +00:00
Douglas Gregor 71944203de Switch the module-loading interfaces and parser from a simple
top-level module name to a module path (e.g., std.vector). We're still
missing a number of pieces for this actually to do something.

llvm-svn: 145462
2011-11-30 00:36:36 +00:00
Douglas Gregor 70db54f18d Eliminate the -emit-module option, which emitted a module by parsing a
source file (e.g., a header). Immediately steal this useful option
name for building modules from a module map file.

llvm-svn: 145444
2011-11-29 22:42:06 +00:00
Douglas Gregor f545f67de3 Switch on-demand module building over to use module maps, always. When
we infer the module map, we'll just print the module map to a
temporary file and generate the module using that.

llvm-svn: 145436
2011-11-29 21:59:16 +00:00
Douglas Gregor 514b636ada Teach the module import mechanism how to rebuild modules expressed via
module map, rather than assuming that there is an umbrella
header. This allows us to automatically build umbrella-less modules. 

llvm-svn: 145415
2011-11-29 19:06:37 +00:00
Douglas Gregor 6dc57927ea Start refactoring to use module maps when rebuilding a module
on-the-fly. No functionality change.

llvm-svn: 145414
2011-11-29 18:31:39 +00:00
Argyrios Kyrtzidis 85b4a37d59 Initialize NumWarningsInPreamble in ASTUnit's constructor, for safety.
llvm-svn: 145412
2011-11-29 18:18:33 +00:00
Benjamin Kramer 696894a35b Silence GCC warnings, RefCountedBase is meant to be default-initialized here.
llvm-svn: 145396
2011-11-29 11:31:35 +00:00
Eli Friedman b0692cb858 Add a couple more GCC versions to C++ search paths for MinGW. Patch by Ruben Van Boxem.
(We should probably start doing some sort of autodetection like we do on Linux at some point.)

llvm-svn: 145326
2011-11-28 23:58:55 +00:00
Douglas Gregor ca295457e5 When attempting to load a module that is not in the module cache,
return the module itself (in the module map) rather than returning the
umbrella header used to build the module. While doing this, make sure
that we're inferring modules for frameworks to build that module.

llvm-svn: 145310
2011-11-28 23:16:06 +00:00
Benjamin Kramer c7ccd616b1 Add missing equals.
llvm-svn: 145290
2011-11-28 22:17:09 +00:00
Argyrios Kyrtzidis b11f5a4cbb [libclang] Indexing API: If the client requested to get a CXTranslationUnit after
indexing, honor all the TU options.

llvm-svn: 145229
2011-11-28 04:56:00 +00:00
Argyrios Kyrtzidis 67aa7db0a4 [libclang] Indexing API: Capture diagnostics during indexing.
llvm-svn: 145228
2011-11-28 04:55:55 +00:00
Rafael Espindola 04268df8ed Set __OPTIMIZE_SIZE__ on -Os and -Oz. This matches gcc's behaviour on both OS X
and linux.

llvm-svn: 145142
2011-11-26 06:21:20 +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
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
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
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
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
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
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
Kostya Serebryany 8855ff61cb Add -f[no-]address-sanitizer flag
llvm-svn: 144800
2011-11-16 17:34:26 +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
Argyrios Kyrtzidis 516eec2d8b [libclang] Fix crash on invalid code. Fixes rdar://10451854
llvm-svn: 144766
2011-11-16 02:35:10 +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
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
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
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
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
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
Devang Patel 9957e8b789 Remove extra ';'.
llvm-svn: 144604
2011-11-15 01:30:40 +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
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
Benjamin Kramer 931ee8e727 serialized diagnostics: simplify code.
llvm-svn: 144277
2011-11-10 11:29:20 +00:00
Ted Kremenek d010ba4729 serialized diagnostics: implement full deserialization of clang diagnostics via the libclang API.
I've tested it on simple cases and it works.  Test cases to follow as well as a few tweaks.

llvm-svn: 144269
2011-11-10 08:43:12 +00:00
Ted Kremenek cc88d264eb serialized diagnostics: serialize the version info in a separate meta block.
llvm-svn: 144115
2011-11-08 20:27:29 +00:00
Douglas Gregor 61d63d0fd7 ASTConsumer::handleTopLevelDecl will end up getting called for
function template instantiations. Fixes <rdar://problem/10398005> / PR11312.

llvm-svn: 143984
2011-11-07 18:53:57 +00:00
Chandler Carruth a62ba81682 Rip out one of the features I added for the driver-include-management.
We don't actually need a separate flag for non-sysrooted paths as the
driver has to manage the sysroot anyways. The driver is not infrequently
adding paths to the header search based on their existence on the
filesystem. For that, it has to add the sysroot anyways, we should pass
it on down to CC1 already joined. More importantly, the driver cannot in
all cases distinguish between sysrooted paths and paths that are
relative to the Clang binary's installation directory. Essentially, we
always need to ignore the system root for these internal header search
options. It turns out in most of the places we were already providing
the system root in the driver, and then another one in CC1 so this fixes
several bugs.

llvm-svn: 143917
2011-11-07 09:17:31 +00:00
Chandler Carruth a796f53821 Move the Linux header searching from the Frontend to the Driver. This is
the first (and diff-noisiest) step to making Linux header searching
tremendously more principled and less brittle. Note that this step
should have essentially no functional impact. We still search the exact
same set of paths in the exact same order. The only change here is where
the code implementing such a search lives.

This has one obvious negative impact -- we now pass a ludicrous number
of flags to the CC1 layer. That should go away as I re-base this logic
on the logic to detect a GCC installation. I want to do this in two
phases so the bots can tell me if this step alone breaks something, and
so that the diffs of the refactoring make more sense.

llvm-svn: 143822
2011-11-05 20:17:13 +00:00
Chandler Carruth d9e10ecb68 Fix a significant oversight in my move of MSVC includes to the driver:
actually manage the builtin header file includes as well as the system
ones.

This one is actually debatable whether it belongs in the driver or not,
as the builtin includes are really an internal bit of implementation
goop for Clang. However, they must be included at *exactly* the right
point in the sequence of header files, which makes it essentially
impossible to have this be managed by the Frontend and the rest by the
Driver. I have terrible ideas that would "work", but I think they're
worse than putting this in the driver and making the Frontend library
even more ignorant of the environment and system on which it is being
run.

Also fix the fact that we weren't properly respecting the flags which
suppress standard system include directories.

Note that this still leaves all of the Clang tests which run CC1
directly and include builtin header files broken on Windows. I'm working
on a followup patch to address that.

llvm-svn: 143801
2011-11-05 09:24:44 +00:00
Chandler Carruth 611cb64453 Add two flags to the CC1 layer that I was hoping to avoid. We need to
encode the *exact* semantics which the header search paths internally
built by the Frontend layer have had, which is both non-user-provided,
and at times adding the implicit extern "C" bit to the directory entry.

There are lots of CC1 options that are very close, but none do quite
this, and they are all already overloaded for other purposes. In some
senses this makes the command lines more clean as it clearly indicates
which flags are exclusively used to implement internal detection of
"standard" header search paths.

Lots of the implementation of this is really crufty, due to the
surrounding cruft. It doesn't seem worth investing lots of time cleaning
this up as it isn't new, and hopefully *lots* of this code will melt
away as header search inside of the frontend becomes increasingly
trivial.

llvm-svn: 143798
2011-11-05 08:30:29 +00:00
Ted Kremenek d89a827b5c serialized diagnostics: include FixIt information in serialized diagnostics.
llvm-svn: 143776
2011-11-05 03:34:23 +00:00
Ted Kremenek f264a20721 serialized diagnostics: pull emission of filenames into diagnostic block.
llvm-svn: 143765
2011-11-05 00:10:11 +00:00
Ted Kremenek 0a49dae7f7 serialized diagnostics: pull emission of diagnostic flag string into diagnostics block.
llvm-svn: 143764
2011-11-05 00:10:07 +00:00
Ted Kremenek 31921506b4 Serialized diagnostics: pull category name serialization into diagnostic blocks. The goal is to remove BLOCK_STRINGS so that the bitcode file can potentially be streamed.
llvm-svn: 143763
2011-11-05 00:10:04 +00:00
Ted Kremenek 59f1025ca0 serialized diagnostics: emit source ranges.
llvm-svn: 143762
2011-11-05 00:10:01 +00:00
Ted Kremenek 337cd2a8e2 Move definition of record/block IDs for serialized diagnostics to public header.
llvm-svn: 143761
2011-11-05 00:09:57 +00:00
Ted Kremenek 868504ab99 Serialized diagnostics: encode a 24 bit version number as part of the "magic number" of serialized diagnostics.
llvm-svn: 143760
2011-11-05 00:09:53 +00:00
Ted Kremenek 2724b1ffc1 serialized diagnostics: unique warning strings when emitting serialized diagnostics.
llvm-svn: 143759
2011-11-05 00:09:50 +00:00
Ted Kremenek f67bbca1a4 Serialized diagnostics: serialize "notes" as sub diagnostics of warnings and errors.
llvm-svn: 143758
2011-11-05 00:09:47 +00:00
Ted Kremenek fce371acb4 Also include file modification time and size in output of SerializedDiagnosticPrinter.
llvm-svn: 143757
2011-11-05 00:09:43 +00:00
Chandler Carruth df52783e32 Begin the migration of header search logic to the driver, starting with
Windows. There are still FIXMEs and lots of problems with this code.
Some of them will be addressed shortly by my follow-up patches, but most
are going to wait until we isolate this code and can fix it properly.
This version should be no worse than what we had before.

llvm-svn: 143752
2011-11-04 23:49:05 +00:00
Devang Patel 384dfa4f10 Enable -flimit-debug-info by default. Now, clang lazily emits debug info for structs. Original behavior can be restored using -fno-limit-debug-info.
llvm-svn: 143733
2011-11-04 20:05:58 +00:00
Chad Rosier 52d00e4815 Parse the warning options twice. The first pass sets diagnostic state, while
the second pass reports warnings/errors.  This has the effect that we follow 
the more canonical "last option wins" paradigm when there are conflicting 
options.
rdar://10383776

Previously, we parsed the warning options in order.  This caused non-intuitive
behavior:

1) clang test.c -Wnosuchwarning -Wno-unknown-warning-option
Before:
warning: unknown warning option '-Wnosuchwarning' [-Wunknown-warning-option]
1 warning generated.
After:
[0 warning generated.]

2) clang test.c -Wnosuchwarning -Werror=unknown-warning-option
Before:
warning: unknown warning option '-Wnosuchwarning' [-Wunknown-warning-option]
1 warning generated.
After:
error: unknown warning option '-Wnosuchwarning' [-Werror,-Wunknown-warning-option]

3) clang test.c -Werror=unknown-warning-option -Wnosuchwarning -Wno-error=unknown-warning-option -Wnosuchwarning
Before:
error: unknown warning option '-Wnosuchwarning' [-Werror,-Wunknown-warning-option]
warning: unknown warning option '-Wnosuchwarning' [-Wunknown-warning-option]
After:
warning: unknown warning option '-Wnosuchwarning' [-Wunknown-warning-option]
warning: unknown warning option '-Wnosuchwarning' [-Wunknown-warning-option]
2 warnings generated.

4) clang test.c -Werror=unknown-warning-option -Wnosuchwarning -Wno-error=unknown-warning-option -Wno-unknown-warning-option -Wnosuchwarning
Before:
error: unknown warning option '-Wnosuchwarning' [-Werror,-Wunknown-warning-option]

After:
[0 warning generated.]

llvm-svn: 143657
2011-11-03 21:23:39 +00:00
Argyrios Kyrtzidis 462ff35d44 After resetting the diagnostic state, set the number of warning occurring in the preamble.
llvm-svn: 143647
2011-11-03 20:57:33 +00:00
Argyrios Kyrtzidis f50f7b2c65 [libclang] Fix crash when a #pragma diagnostic is included in the preamble.
A PCH file keeps track of #pragma diagnostics state; when loading the preamble, they conflicted
with the #pragma diagnostic state already present in the DiagnosticsEngine object due to
parsing the preamble.

Fix this by clearing the state of the DiagnosticsEngine object.
Fixes rdar://10363572 && http://llvm.org/PR11254.

llvm-svn: 143644
2011-11-03 20:28:19 +00:00
Argyrios Kyrtzidis e968152564 [libclang] Add infrastructure to be able to only deserialize decls in a file region and
use it for clang_getCursor.

llvm-svn: 143605
2011-11-03 02:20:32 +00:00
Douglas Gregor 07216d174e Fix various minor issues find via unreachable code warnings, from
Ahmed Charles!

llvm-svn: 143569
2011-11-02 20:52:01 +00:00
Chandler Carruth e0a89ab702 Add the newest Gentoo GCC version based on the reported installed
version in PR11298.

I hear-by apologize for adding yet more code to this monstrosity.

llvm-svn: 143567
2011-11-02 20:09:56 +00:00
Eli Friedman 055c970839 Add an option to emulate the strange Apple gcc behavior of #pragma pack.
<rdar://problem/10374763>

llvm-svn: 143527
2011-11-02 01:53:16 +00:00
Sebastian Pop 8188c8a1f3 rename getHostTriple into getDefaultTargetTriple in clang
llvm-svn: 143503
2011-11-01 21:33:06 +00:00
Argyrios Kyrtzidis 244ce8b204 Put a reference of the ASTReader in the ASTUnit.
This is intended for direct access of the ASTReader for uses that make
little sense to try to shoehorn in the ExternalASTSource interface.

llvm-svn: 143465
2011-11-01 17:14:15 +00:00
Argyrios Kyrtzidis 3689337c8e Revert r143342. Caching of code-completion results was intentionally placed in "reparse"
because we don't want to take this performance hit when doing code completion

Log of r143342:
Move caching of code-completion results from ASTUnit::Reparse to ASTUnit::CodeComplete,
so that it will happen when we are doing code-completion, not reparsing.

llvm-svn: 143367
2011-10-31 21:25:31 +00:00
Chandler Carruth 68ed0ae51c Add "just one more" include path to the monstrosity that is our header
search logic. The Debian multiarch seems to have completely changed from
when these were originally added, and I'd like to remove a bunch of
them, but I'll be lazy and delay that until this logic is hoisted into
the driver where it belongs.

This should resolve PR11223.

llvm-svn: 143345
2011-10-31 08:42:27 +00:00
Argyrios Kyrtzidis 1b544e3cf0 Move caching of code-completion results from ASTUnit::Reparse to ASTUnit::CodeComplete,
so that it will happen when we are doing code-completion, not reparsing.

llvm-svn: 143342
2011-10-31 07:20:19 +00:00
Argyrios Kyrtzidis e54568d657 Have the ASTUnit associate the local declarations that get parsed with the file
that contains them.

llvm-svn: 143338
2011-10-31 07:19:59 +00:00
Peter Collingbourne f1d76db466 Add support for lazily linking bitcode files (using a new
-mlink-bitcode-file flag), and more generally llvm::Modules, before
running optimisations.

llvm-svn: 143314
2011-10-30 17:30:44 +00:00
Ted Kremenek 4610ea2bcf Start work on SerializedDiagnosticPrinter, a new DiagnosticConsumer that serializes out the diagnostics for a given translation unit to a bit code file. This is a WIP.
The motivation for this new DiagnosticConsumer is to provide a way for tools invoking the compiler
to get its diagnostics via a libclang interface, rather than textually parsing the compiler output.
This gives us flexibility to change the compiler's textual output, but have a structured data format
for clients to use to get the diagnostics via a stable API.

I have no tests for this, but llvm-bcanalyzer so far shows that the emitted file is well-formed.

More work to follow.

llvm-svn: 143259
2011-10-29 00:12:39 +00:00
Douglas Gregor 2c4542d3ec Give __STDC_VERSION__ the value 201001L when we're in C1x mode. The
committee hasn't set a value for __STDC_VERSION__ yet, so this is a
placeholder. But at least it's > 199901L.

llvm-svn: 143245
2011-10-28 23:02:54 +00:00
Argyrios Kyrtzidis b12986f1cb Make -error-on-deserialized-decl work correctly by correctly delegating to
the previous ASTDeserializationListener.

llvm-svn: 143241
2011-10-28 22:54:31 +00:00
Ted Kremenek bd307a5372 Add mutex for accessing ASTUnit's global OnDisk data. This may be an issue as libclang could be processing multiple ASTUnit's at once.
llvm-svn: 143138
2011-10-27 19:44:25 +00:00
Ted Kremenek 06b4f919e8 Move ASTUnit's handling of temporary files and the preamble file into a lazily-created static DenseMap. This DenseMap is cleared (and the files erased) via an atexit routine in the case an ASTUnit is not destroyed. Fixes <rdar://problem/10293367>.
llvm-svn: 143115
2011-10-27 17:55:18 +00:00
Argyrios Kyrtzidis 429ec024f8 [PCH] When visiting preprocessed entities, make it possible to avoid deserializing
preprocessed entities that are #included in the range that we are interested.

This is useful when we are interested in preprocessed entities of a specific file, e.g
when we are annotating tokens. There is also an optimization where we cache the last
result of PreprocessingRecord::getPreprocessedEntitiesInRange and we re-use it if
there is a call with the same range as before.

rdar://10313365

llvm-svn: 142887
2011-10-25 00:29:50 +00:00
Chandler Carruth 8c43e66336 Switch to a more natural formatting of the macro name printing.
Suggested by John McCall.

llvm-svn: 142836
2011-10-24 18:51:08 +00:00
Argyrios Kyrtzidis 067cbfa299 [libclang] Make sure we don't try to erase past the StoredDiagnostics vector.
Ted came upon the bug but I couldn't make a test out of it.

llvm-svn: 142805
2011-10-24 17:25:20 +00:00
Douglas Gregor 9885f6153f Make -fms-compatibility imply -fms-extensions. Fixes PR11204.
llvm-svn: 142797
2011-10-24 15:27:23 +00:00
Nick Lewycky ba743b75cb Take DW_AT_comp_dir from $PWD when it's present and starts with a '/'. This is
closer to what GCC does, except that GCC also checks that the inodes for $PWD
and '.' match.

llvm-svn: 142633
2011-10-21 02:32:14 +00:00
Eli Friedman 7bba3ef862 Define __STDC__ in -fms-extensions mode; defining it is consistent with gcc, and not defining it causes the system headers on multiple platforms to break with -fms-extensions because they assume the lack of a definition of __STDC__ implies a traditional (pre-ANSI) preprocessor. PR10324 and <rdar://problem/10313809> .
llvm-svn: 142554
2011-10-19 23:46:05 +00:00
Daniel Dunbar b274318bba Frontend: Support -iframework.
llvm-svn: 142418
2011-10-18 20:40:38 +00:00
Nick Lewycky 1d617acef9 Wire up support for the controlling the extended dwarf .file directive. With
r142300 but not this patch, clang -S may emit .s files that assemblers other
than llvm-mc can't parse.

llvm-svn: 142301
2011-10-17 23:05:52 +00:00
Douglas Gregor 71129d5e9e When building a module, use the macro definitions on the command line
as part of the hash rather than ignoring them. This means we'll end up
building more module variants (overall), but it allows configuration
macros such as NDEBUG to work so long as they're specified via command
line. More to come in this space.

llvm-svn: 142187
2011-10-17 14:55:37 +00:00
Chandler Carruth 724a1ca207 Hoist the logic I added to compute the macro name into a helper
function. No functionality changed.

llvm-svn: 142128
2011-10-16 09:39:09 +00:00
Chandler Carruth 9e8ce4ccb9 Now that macro expansion notes are real notes and go through the same
formatting as any other diagnostic, they will be properly line wrapped and
otherwise pretty printed. Let's take advantage of that and the new factoring to
add some helpful information to them (much like template backtrace notes and
other notes): the name of the macro whose expansion is being noted. This makes
a world of difference if caret diagnostics are disabled, making the expansion
notes actually useful in this case. It also helps ensure that in edge cases the
information the user needs is present. Consider:

% nl -ba t5.cc
     1  #define M(x, y, z) \
     2    y
     3
     4  M(
     5    1,
     6    2,
     7    3);

We now produce:
% ./bin/clang -fsyntax-only t5.cc
t5.cc:6:3: error: expected unqualified-id
  2,
  ^
t5.cc:2:3: note: expanded from macro: M
  y
  ^
1 error generated.

Without the added information in the note, the name of the macro being expanded
would never be shown.

This also deletes a FIXME to use the diagnostic formatting. It's not yet clear
to me that we *can* do this reasonably, and the production of this message was
my primary goal here anyways.

I'd love any comments or suggestions on improving these notes, their wording,
etc. Currently, I need to make them provide more helpful information in the
presence of a token-pasting buffer, and I'm pondering adding something along
the lines of "expanded from argument N of macro: ...".

llvm-svn: 142127
2011-10-16 09:30:08 +00:00