diff --git a/CMakeLists.txt b/CMakeLists.txt index b1ab11de72df..7b54deaaf546 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) include(AddLLVM) include(TableGen) - include("${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVM.cmake") + include("${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake") include(HandleLLVMOptions) set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") @@ -40,9 +40,6 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) set(CMAKE_INCLUDE_CURRENT_DIR ON) include_directories("${PATH_TO_LLVM_BUILD}/include" "${LLVM_MAIN_INCLUDE_DIR}") - if( NOT PATH_TO_LLVM_BUILD STREQUAL LLVM_MAIN_SRC_DIR ) - include_directories("${LLVM_MAIN_INCLUDE_DIR}") - endif() link_directories("${PATH_TO_LLVM_BUILD}/lib") set(LLVM_TABLEGEN_EXE "${PATH_TO_LLVM_BUILD}/bin/tblgen") @@ -174,23 +171,12 @@ macro(add_clang_library name) if( LLVM_COMMON_DEPENDS ) add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) endif( LLVM_COMMON_DEPENDS ) - if( LLVM_USED_LIBS ) - foreach(lib ${LLVM_USED_LIBS}) - target_link_libraries( ${name} ${lib} ) - endforeach(lib) - endif( LLVM_USED_LIBS ) - if( LLVM_LINK_COMPONENTS ) - llvm_config(${name} ${LLVM_LINK_COMPONENTS}) - endif( LLVM_LINK_COMPONENTS ) - if (LLVM_COMMON_LIBS) - target_link_libraries(${name} ${LLVM_COMMON_LIBS}) - endif() - if( NOT MINGW ) - get_system_libs(llvm_system_libs) - if( llvm_system_libs ) - target_link_libraries(${name} ${llvm_system_libs}) - endif() - endif() + + target_link_libraries( ${name} ${LLVM_USED_LIBS} ) + llvm_config( ${name} ${LLVM_LINK_COMPONENTS} ) + target_link_libraries( ${name} ${LLVM_COMMON_LIBS} ) + link_system_libs( ${name} ) + add_dependencies(${name} ClangDiagnosticCommon) if(MSVC) get_target_property(cflag ${name} COMPILE_FLAGS) @@ -211,9 +197,9 @@ macro(add_clang_executable name) set_target_properties(${name} PROPERTIES FOLDER "Clang executables") endmacro(add_clang_executable) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/include +include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/include ) install(DIRECTORY include/ @@ -221,7 +207,6 @@ install(DIRECTORY include/ FILES_MATCHING PATTERN "*.def" PATTERN "*.h" - PATTERN "*.td" PATTERN ".svn" EXCLUDE ) diff --git a/Makefile b/Makefile index 1216dadd297e..b6c630aa10af 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,9 @@ CPP.Flags += -I$(PROJ_SRC_DIR)/$(CLANG_LEVEL)/include -I$(PROJ_OBJ_DIR)/$(CLANG_ ifdef CLANG_VENDOR CPP.Flags += -DCLANG_VENDOR='"$(CLANG_VENDOR) "' endif +ifdef CLANG_REPOSITORY_STRING +CPP.Flags += -DCLANG_REPOSITORY_STRING='"$(CLANG_REPOSITORY_STRING)"' +endif # Disable -fstrict-aliasing. Darwin disables it by default (and LLVM doesn't # work with it enabled with GCC), Clang/llvm-gcc don't support it yet, and newer diff --git a/docs/DriverInternals.html b/docs/DriverInternals.html index a7d2da37711e..4f5f0ae112f9 100644 --- a/docs/DriverInternals.html +++ b/docs/DriverInternals.html @@ -88,7 +88,7 @@
The driver was designed to be flexible and easily accomodate +
The driver was designed to be flexible and easily accommodate new uses as we grow the clang and LLVM infrastructure. As one example, the driver can easily support the introduction of tools which have an integrated assembler; something we hope to @@ -218,7 +218,7 @@
The clang driver can dump the results of this stage using the -ccc-print-options flag (which - must preceed any actual command line arguments). For + must precede any actual command line arguments). For example:
$ clang -ccc-print-options -Xarch_i386 -fomit-frame-pointer -Wa,-fast -Ifoo -I foo t.c @@ -490,7 +490,7 @@
The clang driver has no direct correspondant for +
The clang driver has no direct correspondent for "specs". The majority of the functionality that is embedded in specs is in the Tool specific argument translation routines. The parts of specs which control the diff --git a/docs/InternalsManual.html b/docs/InternalsManual.html index 813015ecf659..961198938f20 100644 --- a/docs/InternalsManual.html +++ b/docs/InternalsManual.html @@ -412,7 +412,7 @@ it is rendered.
-In some cases, the front end emits diagnostics when it is clear @@ -422,14 +422,14 @@ deprecated syntax that is easily rewritten into a more modern form. Clang tries very hard to emit the diagnostic and recover gracefully in these and other cases.
-However, for these cases where the fix is obvious, the diagnostic -can be annotated with a code -modification "hint" that describes how to change the code referenced -by the diagnostic to fix the problem. For example, it might add the -missing semicolon at the end of the statement or rewrite the use of a -deprecated construct into something more palatable. Here is one such -example C++ front end, where we warn about the right-shift operator -changing meaning from C++98 to C++0x:
+However, for these cases where the fix is obvious, the diagnostic +can be annotated with a hint (referred to as a "fix-it hint") that +describes how to change the code referenced by the diagnostic to fix +the problem. For example, it might add the missing semicolon at the +end of the statement or rewrite the use of a deprecated construct +into something more palatable. Here is one such example from the C++ +front end, where we warn about the right-shift operator changing +meaning from C++98 to C++0x:
test.cpp:3:7: warning: use of right-shift operator ('>>') in template argument will require parentheses in C++0x @@ -438,33 +438,31 @@ A<100 >> 2> *a; ( )-
Here, the code modification hint is suggesting that parentheses be -added, and showing exactly where those parentheses would be inserted -into the source code. The code modification hints themselves describe -what changes to make to the source code in an abstract manner, which -the text diagnostic printer renders as a line of "insertions" below -the caret line. Other diagnostic -clients might choose to render the code differently (e.g., as -markup inline) or even give the user the ability to automatically fix -the problem.
+Here, the fix-it hint is suggesting that parentheses be added, +and showing exactly where those parentheses would be inserted into the +source code. The fix-it hints themselves describe what changes to make +to the source code in an abstract manner, which the text diagnostic +printer renders as a line of "insertions" below the caret line. Other diagnostic clients might choose +to render the code differently (e.g., as markup inline) or even give +the user the ability to automatically fix the problem.
-All code modification hints are described by the
-CodeModificationHint
class, instances of which should be
-attached to the diagnostic using the << operator in the same way
-that highlighted source ranges and arguments are passed to the
-diagnostic. Code modification hints can be created with one of three
-constructors:
All fix-it hints are described by the FixItHint
class,
+instances of which should be attached to the diagnostic using the
+<< operator in the same way that highlighted source ranges and
+arguments are passed to the diagnostic. Fix-it hints can be created
+with one of three constructors:
CodeModificationHint::CreateInsertion(Loc, Code)
FixItHint::CreateInsertion(Loc, Code)
Code
(a string) should be inserted
before the source location Loc
.CodeModificationHint::CreateRemoval(Range)
FixItHint::CreateRemoval(Range)
Range
should be removed.CodeModificationHint::CreateReplacement(Range, Code)
FixItHint::CreateReplacement(Range, Code)
Range
should be removed, and replaced with the given Code
string.Language extensions can be very useful, but only if you know you can depend -on them. In order to allow fine-grain features checks, we support two builtin +on them. In order to allow fine-grain features checks, we support three builtin function-like macros. This allows you to directly test for a feature in your code without having to resort to something like autoconf or fragile "compiler version checks".
@@ -402,9 +403,19 @@ lambdas is enabled. clang does not currently implement this feature. nullptr is enabled. clang does not yet fully implement this feature. +Use __has_feature(cxx_override_control) to determine if support for +the override control keywords is enabled.
+Use __has_feature(cxx_reference_qualified_functions) to determine if support for reference-qualified functions (e.g., member functions with &
or &&
applied to *this
) is enabled.
Use __has_feature(cxx_range_for) to determine if support for +the range-based for loop is enabled.
+Use __has_feature(cxx_rvalue_references) to determine if support for @@ -436,6 +447,11 @@ inline namespaces is enabled.
Use __has_feature(cxx_trailing_return) to determine if support for the alternate function declaration syntax with trailing return type is enabled.
+Use __has_feature(cxx_noexcept) to determine if support for +noexcept exception specifications is enabled.
+Use __has_feature(cxx_strong_enums) to determine if support for @@ -594,6 +610,20 @@ caveats to this use of name mangling:
Query for this feature with __has_feature(attribute_overloadable).
+ +The C1X generic selection expression is available in all languages +supported by Clang. The syntax is the same as that given in the C1X draft +standard.
+ +In C, type compatibility is decided according to the rules given in the +appropriate standard, but in C++, which lacks the type compatibility rules +used in C, types are considered compatible only if they are equivalent.
+ +Query for this feature with __has_feature(generic_selections).
+Query for this feature with __has_builtin(__builtin_unreachable).
+ +__sync_swap is used to atomically swap integers or pointers in +memory. +
+ +Syntax:
+ ++type __sync_swap(type *ptr, type value, ...) ++ +
Example of Use:
+ ++int old_value = __sync_swap(&value, new_value); ++ +
Description:
+ +The __sync_swap() builtin extends the existing __sync_*() family of atomic +intrinsics to allow code to atomically swap the current value with the new +value. More importantly, it helps developers write more efficient and correct +code by avoiding expensive loops around __sync_bool_compare_and_swap() or +relying on the platform specific implementation details of +__sync_lock_test_and_set(). The __sync_swap() builtin is a full barrier. +
+Clang's static analysis engine understands the standard noreturn attribute. This attribute, which is typically affixed to a function prototype, @@ -786,16 +842,47 @@ placed at the end of function prototypes:
void foo() __attribute__((analyzer_noreturn)); -Query for this feature with __has_feature(attribute_analyzer_noreturn).
+Query for this feature with +__has_attribute(analyzer_noreturn).
-Many methods in Objective-C have conventional meanings determined
+by their selectors. For the purposes of static analysis, it is
+sometimes useful to be able to mark a method as having a particular
+conventional meaning despite not having the right selector, or as not
+having the conventional meaning that its selector would suggest.
+For these use cases, we provide an attribute to specifically describe
+the method family
that a method belongs to.
Usage: __attribute__((objc_method_family(X))), +where X is one of none, alloc, copy, +init, mutableCopy, or new. This attribute +can only be placed at the end of a method declaration:
+ ++ - (NSString*) initMyStringValue __attribute__((objc_method_family(none))); ++ +
Users who do not wish to change the conventional meaning of a +method, and who merely want to document its non-standard retain and +release semantics, should use the +retaining behavior attributes +described below.
+ +Query for this feature with +__has_attribute(objc_method_family).
+ +In Objective-C, functions and methods are generally assumed to take and return objects with +0 retain counts, with some exceptions for special methods like +alloc and init. However, there are exceptions, and so Clang provides attributes to allow these exceptions to be documented, which helps the analyzer find leaks (and -ignore non-leaks).
+ignore non-leaks). Some exceptions may be better described using +the objc_method_family +attribute instead.Usage: The ns_returns_retained, ns_returns_not_retained, ns_returns_autoreleased, cf_returns_retained, @@ -834,6 +921,9 @@ balance in some way.
- (void) baz: (id) __attribute__((ns_consumed)) x; +Query for these features with __has_attribute(ns_consumed), +__has_attribute(ns_returns_retained), etc.
+