[llvm-branch-commits] [cfe-branch] r151016 [2/2] - in /cfe/branches/tooling: ./ INPUTS/ bindings/python/clang/ bindings/python/tests/cindex/ docs/ include/clang-c/ include/clang/AST/ include/clang/ASTMatchers/ include/clang/Analysis/Analyses/ include/clang/Basic/ include/clang/Driver/ include/clang/Frontend/ include/clang/Parse/ include/clang/Sema/ include/clang/Serialization/ include/clang/StaticAnalyzer/Core/ include/clang/StaticAnalyzer/Core/PathSensitive/ lib/AST/ lib/Analysis/ lib/Basic/ lib/CodeGen/ lib/Driver/ lib/Fron...
Manuel Klimek
klimek at google.com
Mon Feb 20 17:34:26 PST 2012
Modified: cfe/branches/tooling/test/SemaCXX/deleted-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/deleted-function.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/deleted-function.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/deleted-function.cpp Mon Feb 20 19:34:24 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fcxx-exceptions %s
int i = delete; // expected-error {{only functions can have deleted definitions}}
@@ -33,3 +33,25 @@
d->fn(); // expected-error {{attempt to use a deleted function}}
int i = *d; // expected-error {{invokes a deleted function}}
}
+
+struct DelDtor {
+ ~DelDtor() = delete; // expected-note 9{{here}}
+};
+void f() {
+ DelDtor *p = new DelDtor[3]; // expected-error {{attempt to use a deleted function}}
+ delete [] p; // expected-error {{attempt to use a deleted function}}
+ const DelDtor &dd2 = DelDtor(); // expected-error {{attempt to use a deleted function}}
+ DelDtor dd; // expected-error {{attempt to use a deleted function}}
+ throw dd; // expected-error {{attempt to use a deleted function}}
+}
+struct X : DelDtor {
+ ~X() {} // expected-error {{attempt to use a deleted function}}
+};
+struct Y {
+ DelDtor dd;
+ ~Y() {} // expected-error {{attempt to use a deleted function}}
+};
+struct Z : virtual DelDtor {
+ ~Z() {} // expected-error {{attempt to use a deleted function}}
+};
+DelDtor dd; // expected-error {{attempt to use a deleted function}}
Removed: cfe/branches/tooling/test/SemaCXX/if-empty-body.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/if-empty-body.cpp?rev=151015&view=auto
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/if-empty-body.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/if-empty-body.cpp (removed)
@@ -1,35 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-void f1(int a) {
- if (a); // expected-warning {{if statement has empty body}}
-}
-
-void f2(int a) {
- if (a) {}
-}
-
-void f3() {
- if (1)
- xx; // expected-error {{use of undeclared identifier}}
- return; // no empty body warning.
-}
-
-// Don't warn about an empty body if is expanded from a macro.
-void f4(int i) {
- #define BODY(x)
- if (i == i) // expected-warning{{self-comparison always evaluates to true}}
- BODY(0);
- #undef BODY
-}
-
-template <typename T>
-void tf() {
- #define BODY(x)
- if (0)
- BODY(0);
- #undef BODY
-}
-
-void f5() {
- tf<int>();
-}
Modified: cfe/branches/tooling/test/SemaCXX/implicit-exception-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/implicit-exception-spec.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/implicit-exception-spec.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/implicit-exception-spec.cpp Mon Feb 20 19:34:24 2012
@@ -54,10 +54,9 @@
// The same problem arises in delayed parsing of default arguments,
// which clang does not yet support.
namespace DefaultArgument {
- // FIXME: this diagnostic is completely wrong.
- struct Default { // expected-note {{explicitly marked deleted here}}
+ struct Default { // expected-note {{defined here}}
struct T {
- T(int = ExceptionIf<noexcept(Default())::f()); // expected-error {{call to deleted constructor}}
+ T(int = ExceptionIf<noexcept(Default())::f()); // expected-error {{call to implicitly-deleted default constructor}}
} t;
};
}
Modified: cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/lambda-expressions.cpp Mon Feb 20 19:34:24 2012
@@ -78,7 +78,7 @@
struct G { G(); G(G&); int a; }; // expected-note 6 {{not viable}}
G g;
[=]() { const G* gg = &g; return gg->a; }; // expected-warning{{omitted result type}}
- [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'const ImplicitCapture::G'}} \
+ [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'ImplicitCapture::G'}} \
// expected-warning{{omitted result type}}
(void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const ImplicitCapture::G'}} \
// expected-warning{{omitted result type}}
Modified: cfe/branches/tooling/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp Mon Feb 20 19:34:24 2012
@@ -74,3 +74,49 @@
(void)new llvm::GraphWriter; // expected-error {{expected a type}}
(void)new llvm::Graphwriter<S>; // expected-error {{no template named 'Graphwriter' in namespace 'llvm'; did you mean 'GraphWriter'?}}
}
+
+// If namespace prefixes and character edits have the same weight, correcting
+// "fimish" to "N::famish" would have the same edit distance as correcting
+// "fimish" to "Finish". The result would be no correction being suggested
+// unless one of the corrections is given precedence (e.g. by filtering out
+// suggestions with added namespace qualifiers).
+namespace N { void famish(int); }
+void Finish(int); // expected-note {{'Finish' declared here}}
+void Start() {
+ fimish(7); // expected-error {{use of undeclared identifier 'fimish'; did you mean 'Finish'?}}
+}
+
+// But just eliminating the corrections containing added namespace qualifiers
+// won't work if both of the tied corrections have namespace qualifiers added.
+namespace N {
+void someCheck(int); // expected-note {{'N::someCheck' declared here}}
+namespace O { void somechock(int); }
+}
+void confusing() {
+ somechick(7); // expected-error {{use of undeclared identifier 'somechick'; did you mean 'N::someCheck'?}}
+}
+
+
+class Message {};
+namespace extra {
+ namespace util {
+ namespace MessageUtils {
+ bool Equivalent(const Message&, const Message&); // expected-note {{'extra::util::MessageUtils::Equivalent' declared here}} \
+ // expected-note {{'::extra::util::MessageUtils::Equivalent' declared here}}
+ }
+ }
+}
+namespace util { namespace MessageUtils {} }
+bool nstest () {
+ Message a, b;
+ return util::MessageUtils::Equivalent(a, b); // expected-error {{no member named 'Equivalent' in namespace 'util::MessageUtils'; did you mean 'extra::util::MessageUtils::Equivalent'?}}
+}
+
+namespace util {
+ namespace extra {
+ bool nstest () {
+ Message a, b;
+ return MessageUtils::Equivalent(a, b); // expected-error {{no member named 'Equivalent' in namespace 'util::MessageUtils'; did you mean '::extra::util::MessageUtils::Equivalent'?}}
+ }
+ }
+}
Modified: cfe/branches/tooling/test/SemaCXX/new-delete-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/new-delete-cxx0x.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/new-delete-cxx0x.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/new-delete-cxx0x.cpp Mon Feb 20 19:34:24 2012
@@ -7,3 +7,20 @@
(void)new int[-1]; // expected-warning {{array size is negative}}
(void)new int[2000000000]; // expected-warning {{array is too large}}
}
+
+
+struct S {
+ S(int);
+ S();
+ ~S();
+};
+
+struct T { // expected-note 2 {{not viable}}
+ T(int); // expected-note {{not viable}}
+};
+
+void fn() {
+ (void) new int[2] {1, 2};
+ (void) new S[2] {1, 2};
+ (void) new T[2] {1, 2}; // expected-error {{no matching constructor}}
+}
Modified: cfe/branches/tooling/test/SemaCXX/new-delete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/new-delete.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/new-delete.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/new-delete.cpp Mon Feb 20 19:34:24 2012
@@ -417,3 +417,46 @@
};
void f(A *x) { delete x; } // expected-warning {{delete called on 'PR10504::A' that is abstract but has non-virtual destructor}}
}
+
+struct PlacementArg {};
+inline void *operator new[](size_t, const PlacementArg &) throw () {
+ return 0;
+}
+inline void operator delete[](void *, const PlacementArg &) throw () {
+}
+
+namespace r150682 {
+
+ template <typename X>
+ struct S {
+ struct Inner {};
+ S() { new Inner[1]; }
+ };
+
+ struct T {
+ };
+
+ template<typename X>
+ void tfn() {
+ new (*(PlacementArg*)0) T[1];
+ }
+
+ void fn() {
+ tfn<int>();
+ }
+
+}
+
+namespace P12023 {
+ struct CopyCounter
+ {
+ CopyCounter();
+ CopyCounter(const CopyCounter&);
+ };
+
+ int main()
+ {
+ CopyCounter* f = new CopyCounter[10](CopyCounter()); // expected-error {{cannot have initialization arguments}}
+ return 0;
+ }
+}
Modified: cfe/branches/tooling/test/SemaCXX/nullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/nullptr.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/nullptr.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/nullptr.cpp Mon Feb 20 19:34:24 2012
@@ -109,19 +109,30 @@
}
}
-int array0[__is_scalar(nullptr_t)? 1 : -1];
-int array1[__is_pod(nullptr_t)? 1 : -1];
-int array2[sizeof(nullptr_t) == sizeof(void*)? 1 : -1];
-
-// FIXME: when we implement constexpr, this will be testable.
-#if 0
-int relational0[nullptr < nullptr? -1 : 1];
-int relational1[nullptr > nullptr? -1 : 1];
-int relational2[nullptr <= nullptr? 1 : -1];
-int relational3[nullptr >= nullptr? 1 : -1];
-int equality[nullptr == nullptr? 1 : -1];
-int inequality[nullptr != nullptr? -1 : 1];
-#endif
+static_assert(__is_scalar(nullptr_t), "");
+static_assert(__is_pod(nullptr_t), "");
+static_assert(sizeof(nullptr_t) == sizeof(void*), "");
+
+static_assert(!(nullptr < nullptr), "");
+static_assert(!(nullptr > nullptr), "");
+static_assert( nullptr <= nullptr, "");
+static_assert( nullptr >= nullptr, "");
+static_assert( nullptr == nullptr, "");
+static_assert(!(nullptr != nullptr), "");
+
+static_assert(!(0 < nullptr), "");
+static_assert(!(0 > nullptr), "");
+static_assert( 0 <= nullptr, "");
+static_assert( 0 >= nullptr, "");
+static_assert( 0 == nullptr, "");
+static_assert(!(0 != nullptr), "");
+
+static_assert(!(nullptr < 0), "");
+static_assert(!(nullptr > 0), "");
+static_assert( nullptr <= 0, "");
+static_assert( nullptr >= 0, "");
+static_assert( nullptr == 0, "");
+static_assert(!(nullptr != 0), "");
namespace overloading {
int &f1(int*);
@@ -161,3 +172,14 @@
X2<nullptr, nullptr, nullptr, nullptr> x2;
}
+
+namespace null_pointer_constant {
+
+// Pending implementation of core issue 903, ensure we don't allow any of the
+// C++11 constant evaluation semantics in null pointer constants.
+struct S { int n; };
+constexpr int null() { return 0; }
+void *p = S().n; // expected-error {{cannot initialize}}
+void *q = null(); // expected-error {{cannot initialize}}
+
+}
Modified: cfe/branches/tooling/test/SemaCXX/switch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/switch.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/switch.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/switch.cpp Mon Feb 20 19:34:24 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
void test() {
bool x = true;
@@ -64,3 +64,24 @@
case 0: ;
}
}
+
+void local_class(int n) {
+ for (;;) switch (n) {
+ case 0:
+ struct S {
+ void f() {
+ case 1: // expected-error {{'case' statement not in switch statement}}
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ default: // expected-error {{'default' statement not in switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ }
+ };
+ S().f();
+ []{
+ case 2: // expected-error {{'case' statement not in switch statement}}
+ break; // expected-error {{'break' statement not in loop or switch statement}}
+ default: // expected-error {{'default' statement not in switch statement}}
+ continue; // expected-error {{'continue' statement not in loop statement}}
+ }();
+ }
+}
Modified: cfe/branches/tooling/test/SemaCXX/typo-correction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/typo-correction.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/typo-correction.cpp Mon Feb 20 19:34:24 2012
@@ -157,3 +157,13 @@
void RangeTest() {
for (auto b : R()) {} // expected-error {{use of undeclared identifier 'begin'}} expected-note {{range has type}}
}
+
+// PR 12019 - Avoid infinite mutual recursion in DiagnoseInvalidRedeclaration
+// by not trying to typo-correct a method redeclaration to declarations not
+// in the current record.
+class Parent {
+ void set_types(int index, int value);
+ void add_types(int value);
+};
+class Child: public Parent {};
+void Child::add_types(int value) {} // expected-error{{out-of-line definition of 'add_types' does not match any declaration in 'Child'}}
Modified: cfe/branches/tooling/test/SemaCXX/value-initialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/value-initialization.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/value-initialization.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/value-initialization.cpp Mon Feb 20 19:34:24 2012
@@ -1,11 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
-struct A { //expected-note {{marked deleted here}} \
+struct A { //expected-note {{defined here}} \
// expected-warning {{does not declare any constructor to initialize}}
const int i; // expected-note{{const member 'i' will never be initialized}}
virtual void f() { }
};
int main () {
- (void)A(); // expected-error {{call to deleted constructor}}
+ (void)A(); // expected-error {{call to implicitly-deleted default constructor}}
}
Modified: cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp Mon Feb 20 19:34:24 2012
@@ -313,12 +313,13 @@
// Test diagnostics for other method names.
class WeirdMethods {
+ // FIXME: can't currently check inside constructors and destructors.
WeirdMethods() {
- wmu.Lock(); // expected-note {{mutex acquired here}}
- } // expected-warning {{mutex 'wmu' is still locked at the end of function}}
+ wmu.Lock(); // EXPECTED-NOTE {{mutex acquired here}}
+ } // EXPECTED-WARNING {{mutex 'wmu' is still locked at the end of function}}
~WeirdMethods() {
- wmu.Lock(); // expected-note {{mutex acquired here}}
- } // expected-warning {{mutex 'wmu' is still locked at the end of function}}
+ wmu.Lock(); // EXPECTED-NOTE {{mutex acquired here}}
+ } // EXPECTED-WARNING {{mutex 'wmu' is still locked at the end of function}}
void operator++() {
wmu.Lock(); // expected-note {{mutex acquired here}}
} // expected-warning {{mutex 'wmu' is still locked at the end of function}}
@@ -1846,6 +1847,7 @@
public:
// Test dependent guarded_by
T data GUARDED_BY(mu_);
+ static T static_data GUARDED_BY(static_mu_);
void fooEx(CellDelayed<T> *other) EXCLUSIVE_LOCKS_REQUIRED(mu_, other->mu_) {
this->data = other->data;
@@ -1863,6 +1865,7 @@
}
Mutex mu_;
+ static Mutex static_mu_;
};
void testDelayed() {
@@ -1936,3 +1939,164 @@
}
}
+
+
+
+namespace FunctionDefinitionTest {
+
+class Foo {
+public:
+ void foo1();
+ void foo2();
+ void foo3(Foo *other);
+
+ template<class T>
+ void fooT1(const T& dummy1);
+
+ template<class T>
+ void fooT2(const T& dummy2) EXCLUSIVE_LOCKS_REQUIRED(mu_);
+
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+template<class T>
+class FooT {
+public:
+ void foo();
+
+ Mutex mu_;
+ T a GUARDED_BY(mu_);
+};
+
+
+void Foo::foo1() NO_THREAD_SAFETY_ANALYSIS {
+ a = 1;
+}
+
+void Foo::foo2() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ a = 2;
+}
+
+void Foo::foo3(Foo *other) EXCLUSIVE_LOCKS_REQUIRED(other->mu_) {
+ other->a = 3;
+}
+
+template<class T>
+void Foo::fooT1(const T& dummy1) EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ a = dummy1;
+}
+
+/* TODO -- uncomment with template instantiation of attributes.
+template<class T>
+void Foo::fooT2(const T& dummy2) {
+ a = dummy2;
+}
+*/
+
+void fooF1(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) {
+ f->a = 1;
+}
+
+void fooF2(Foo *f);
+void fooF2(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) {
+ f->a = 2;
+}
+
+void fooF3(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_);
+void fooF3(Foo *f) {
+ f->a = 3;
+}
+
+template<class T>
+void FooT<T>::foo() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ a = 0;
+}
+
+void test() {
+ int dummy = 0;
+ Foo myFoo;
+
+ myFoo.foo2(); // \
+ // expected-warning {{calling function 'foo2' requires exclusive lock on 'mu_'}}
+ myFoo.foo3(&myFoo); // \
+ // expected-warning {{calling function 'foo3' requires exclusive lock on 'mu_'}}
+ myFoo.fooT1(dummy); // \
+ // expected-warning {{calling function 'fooT1' requires exclusive lock on 'mu_'}}
+
+ // FIXME: uncomment with template instantiation of attributes patch
+ // myFoo.fooT2(dummy); // expected warning
+
+ fooF1(&myFoo); // \
+ // expected-warning {{calling function 'fooF1' requires exclusive lock on 'mu_'}}
+ fooF2(&myFoo); // \
+ // expected-warning {{calling function 'fooF2' requires exclusive lock on 'mu_'}}
+ fooF3(&myFoo); // \
+ // expected-warning {{calling function 'fooF3' requires exclusive lock on 'mu_'}}
+
+ myFoo.mu_.Lock();
+ myFoo.foo2();
+ myFoo.foo3(&myFoo);
+ myFoo.fooT1(dummy);
+
+ // FIXME: uncomment with template instantiation of attributes patch
+ // myFoo.fooT2(dummy);
+
+ fooF1(&myFoo);
+ fooF2(&myFoo);
+ fooF3(&myFoo);
+ myFoo.mu_.Unlock();
+
+ FooT<int> myFooT;
+ myFooT.foo(); // \
+ // expected-warning {{calling function 'foo' requires exclusive lock on 'mu_'}}
+}
+
+} // end namespace FunctionDefinitionTest
+
+
+namespace SelfLockingTest {
+
+class LOCKABLE MyLock {
+public:
+ int foo GUARDED_BY(this);
+
+ void lock() EXCLUSIVE_LOCK_FUNCTION();
+ void unlock() UNLOCK_FUNCTION();
+
+ void doSomething() {
+ this->lock(); // allow 'this' as a lock expression
+ foo = 0;
+ doSomethingElse();
+ this->unlock();
+ }
+
+ void doSomethingElse() EXCLUSIVE_LOCKS_REQUIRED(this) {
+ foo = 1;
+ };
+
+ void test() {
+ foo = 2; // \
+ // expected-warning {{writing variable 'foo' requires locking 'this' exclusively}}
+ }
+};
+
+
+class LOCKABLE MyLock2 {
+public:
+ Mutex mu_;
+ int foo GUARDED_BY(this);
+
+ // don't check inside lock and unlock functions
+ void lock() EXCLUSIVE_LOCK_FUNCTION() { mu_.Lock(); }
+ void unlock() UNLOCK_FUNCTION() { mu_.Unlock(); }
+
+ // don't check inside constructors and destructors
+ MyLock2() { foo = 1; }
+ ~MyLock2() { foo = 0; }
+};
+
+
+} // end namespace SelfLockingTest
+
+
Modified: cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp Mon Feb 20 19:34:24 2012
@@ -1262,3 +1262,30 @@
void unlock() __attribute__((unlock_function())) { }
};
+
+namespace FunctionDefinitionParseTest {
+// Test parsing of attributes on function definitions.
+
+class Foo {
+public:
+ Mu mu_;
+ void foo1();
+ void foo2(Foo *f);
+};
+
+template <class T>
+class Bar {
+public:
+ Mu mu_;
+ void bar();
+};
+
+void Foo::foo1() __attribute__((exclusive_locks_required(mu_))) { }
+void Foo::foo2(Foo *f) __attribute__((exclusive_locks_required(f->mu_))) { }
+
+template <class T>
+void Bar<T>::bar() __attribute__((exclusive_locks_required(mu_))) { }
+
+void baz(Foo *f) __attribute__((exclusive_locks_required(f->mu_))) { }
+};
+
Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 20 19:34:24 2012
@@ -1,2 +1,2 @@
/cfe/branches/type-system-rewrite/test/SemaCXX/warn-unreachable.cpp:134693-134817
-/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-150469
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-150926
Modified: cfe/branches/tooling/test/SemaObjC/illegal-nonarc-bridged-cast.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/illegal-nonarc-bridged-cast.m?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/illegal-nonarc-bridged-cast.m (original)
+++ cfe/branches/tooling/test/SemaObjC/illegal-nonarc-bridged-cast.m Mon Feb 20 19:34:24 2012
@@ -16,19 +16,19 @@
NSString *CreateNSString();
void from_cf() {
- id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts are only allowed when using ARC}}
- id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{'__bridge_transfer' casts are only allowed when using ARC}}
- (__bridge int*)CFCreateSomething(); // expected-warning {{'__bridge' casts are only allowed when using ARC}} \
+ id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
+ id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}}
+ (__bridge int*)CFCreateSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}} \
// expected-warning {{expression result unused}}
- id obj3 = (__bridge id)CFGetSomething(); // expected-warning {{'__bridge' casts are only allowed when using ARC}}
- id obj4 = (__bridge NSString*)CFGetString(); // expected-warning {{'__bridge' casts are only allowed when using ARC}}
+ id obj3 = (__bridge id)CFGetSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+ id obj4 = (__bridge NSString*)CFGetString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
}
void to_cf(id obj) {
- CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{'__bridge_retained' casts are only allowed when using ARC}}
- CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning {{'__bridge_retained' casts are only allowed when using ARC}}
- CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // expected-warning {{'__bridge' casts are only allowed when using ARC}}
- CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning {{'__bridge' casts are only allowed when using ARC}}
+ CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
+ CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}}
+ CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
+ CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning {{'__bridge' casts have no effect when not using ARC}}
}
void fixits() {
Modified: cfe/branches/tooling/test/SemaObjCXX/properties.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjCXX/properties.mm?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjCXX/properties.mm (original)
+++ cfe/branches/tooling/test/SemaObjCXX/properties.mm Mon Feb 20 19:34:24 2012
@@ -68,3 +68,20 @@
if (t5->count < 2) { }
}
+
+ at interface Test6
++ (Class)class;
+- (Class)class;
+ at end
+
+void test6(Test6 *t6) {
+ Class x = t6.class;
+ Class x2 = Test6.class;
+}
+
+template<typename T>
+void test6_template(T *t6) {
+ Class x = t6.class;
+}
+
+template void test6_template(Test6*);
Modified: cfe/branches/tooling/test/SemaTemplate/enum-forward.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/enum-forward.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/enum-forward.cpp (original)
+++ cfe/branches/tooling/test/SemaTemplate/enum-forward.cpp Mon Feb 20 19:34:24 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -fms-compatibility %s
template<typename T>
struct X {
Modified: cfe/branches/tooling/tools/diagtool/ListWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/diagtool/ListWarnings.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/diagtool/ListWarnings.cpp (original)
+++ cfe/branches/tooling/tools/diagtool/ListWarnings.cpp Mon Feb 20 19:34:24 2012
@@ -16,6 +16,8 @@
#include "clang/Basic/Diagnostic.h"
#include "llvm/Support/Format.h"
#include "llvm/ADT/StringMap.h"
+#include "clang/AST/ASTDiagnostic.h"
+#include "clang/Basic/AllDiagnostics.h"
DEF_DIAGTOOL("list-warnings",
"List warnings and their corresponding flags",
@@ -23,6 +25,27 @@
using namespace clang;
+namespace {
+struct StaticDiagNameIndexRec {
+ const char *NameStr;
+ unsigned short DiagID;
+ uint8_t NameLen;
+
+ StringRef getName() const {
+ return StringRef(NameStr, NameLen);
+ }
+};
+}
+
+static const StaticDiagNameIndexRec StaticDiagNameIndex[] = {
+#define DIAG_NAME_INDEX(ENUM) { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) },
+#include "clang/Basic/DiagnosticIndexName.inc"
+#undef DIAG_NAME_INDEX
+ { 0, 0, 0 }
+};
+
+static const unsigned StaticDiagNameIndexSize =
+ sizeof(StaticDiagNameIndex)/sizeof(StaticDiagNameIndex[0])-1;
namespace {
struct Entry {
@@ -47,16 +70,13 @@
}
int ListWarnings::run(unsigned int argc, char **argv, llvm::raw_ostream &out) {
- llvm::IntrusiveRefCntPtr<DiagnosticIDs> Diags(new DiagnosticIDs);
- DiagnosticsEngine D(Diags);
-
std::vector<Entry> Flagged, Unflagged;
llvm::StringMap<std::vector<unsigned> > flagHistogram;
- for (DiagnosticIDs::diag_iterator di = DiagnosticIDs::diags_begin(),
- de = DiagnosticIDs::diags_end(); di != de; ++di) {
+ for (const StaticDiagNameIndexRec *di = StaticDiagNameIndex, *de = StaticDiagNameIndex + StaticDiagNameIndexSize;
+ di != de; ++di) {
- unsigned diagID = di.getDiagID();
+ unsigned diagID = di->DiagID;
if (DiagnosticIDs::isBuiltinNote(diagID))
continue;
@@ -64,7 +84,7 @@
if (!DiagnosticIDs::isBuiltinWarningOrExtension(diagID))
continue;
- Entry entry(di.getDiagName(),
+ Entry entry(di->getName(),
DiagnosticIDs::getWarningOptionForDiag(diagID));
if (entry.Flag.empty())
Modified: cfe/branches/tooling/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CIndex.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CIndex.cpp Mon Feb 20 19:34:24 2012
@@ -1615,6 +1615,7 @@
DEF_JOB(ExplicitTemplateArgsVisit, ASTTemplateArgumentListInfo,
ExplicitTemplateArgsVisitKind)
DEF_JOB(SizeOfPackExprParts, SizeOfPackExpr, SizeOfPackExprPartsKind)
+DEF_JOB(LambdaExprParts, LambdaExpr, LambdaExprPartsKind)
#undef DEF_JOB
class DeclVisit : public VisitorJob {
@@ -1761,6 +1762,7 @@
void VisitSizeOfPackExpr(SizeOfPackExpr *E);
void VisitPseudoObjectExpr(PseudoObjectExpr *E);
void VisitOpaqueValueExpr(OpaqueValueExpr *E);
+ void VisitLambdaExpr(LambdaExpr *E);
private:
void AddDeclarationNameInfo(Stmt *S);
@@ -1854,9 +1856,8 @@
AddStmt(E->getBase());
}
void EnqueueVisitor::VisitCXXNewExpr(CXXNewExpr *E) {
- // Enqueue the initializer or constructor arguments.
- for (unsigned I = E->getNumConstructorArgs(); I > 0; --I)
- AddStmt(E->getConstructorArg(I-1));
+ // Enqueue the initializer , if any.
+ AddStmt(E->getInitializer());
// Enqueue the array size, if any.
AddStmt(E->getArraySize());
// Enqueue the allocated type.
@@ -2081,6 +2082,10 @@
if (Expr *SourceExpr = E->getSourceExpr())
return Visit(SourceExpr);
}
+void EnqueueVisitor::VisitLambdaExpr(LambdaExpr *E) {
+ AddStmt(E->getBody());
+ WL.push_back(LambdaExprParts(E, Parent));
+}
void EnqueueVisitor::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
// Treat the expression like its syntactic form.
Visit(E->getSyntacticForm());
@@ -2258,6 +2263,45 @@
// treated like DeclRefExpr cursors.
continue;
}
+
+ case VisitorJob::LambdaExprPartsKind: {
+ // Visit captures.
+ LambdaExpr *E = cast<LambdaExprParts>(&LI)->get();
+ for (LambdaExpr::capture_iterator C = E->explicit_capture_begin(),
+ CEnd = E->explicit_capture_end();
+ C != CEnd; ++C) {
+ if (C->capturesThis())
+ continue;
+
+ if (Visit(MakeCursorVariableRef(C->getCapturedVar(),
+ C->getLocation(),
+ TU)))
+ return true;
+ }
+
+ // Visit parameters and return type, if present.
+ if (E->hasExplicitParameters() || E->hasExplicitResultType()) {
+ TypeLoc TL = E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
+ if (E->hasExplicitParameters() && E->hasExplicitResultType()) {
+ // Visit the whole type.
+ if (Visit(TL))
+ return true;
+ } else if (isa<FunctionProtoTypeLoc>(TL)) {
+ FunctionProtoTypeLoc Proto = cast<FunctionProtoTypeLoc>(TL);
+ if (E->hasExplicitParameters()) {
+ // Visit parameters.
+ for (unsigned I = 0, N = Proto.getNumArgs(); I != N; ++I)
+ if (Visit(MakeCXCursor(Proto.getArg(I), TU)))
+ return true;
+ } else {
+ // Visit result type.
+ if (Visit(Proto.getResultLoc()))
+ return true;
+ }
+ }
+ }
+ break;
+ }
}
}
return false;
@@ -2980,6 +3024,13 @@
return createCXString((*Ovl->begin())->getNameAsString());
}
+ case CXCursor_VariableRef: {
+ VarDecl *Var = getCursorVariableRef(C).first;
+ assert(Var && "Missing variable decl");
+
+ return createCXString(Var->getNameAsString());
+ }
+
default:
return createCXString("<not implemented>");
}
@@ -3173,6 +3224,8 @@
return createCXString("LabelRef");
case CXCursor_OverloadedDeclRef:
return createCXString("OverloadedDeclRef");
+ case CXCursor_VariableRef:
+ return createCXString("VariableRef");
case CXCursor_IntegerLiteral:
return createCXString("IntegerLiteral");
case CXCursor_FloatingLiteral:
@@ -3251,6 +3304,8 @@
return createCXString("PackExpansionExpr");
case CXCursor_SizeOfPackExpr:
return createCXString("SizeOfPackExpr");
+ case CXCursor_LambdaExpr:
+ return createCXString("LambdaExpr");
case CXCursor_UnexposedExpr:
return createCXString("UnexposedExpr");
case CXCursor_DeclRefExpr:
@@ -3626,6 +3681,11 @@
return cxloc::translateSourceLocation(P.first->getASTContext(), P.second);
}
+ case CXCursor_VariableRef: {
+ std::pair<VarDecl *, SourceLocation> P = getCursorVariableRef(C);
+ return cxloc::translateSourceLocation(P.first->getASTContext(), P.second);
+ }
+
case CXCursor_CXXBaseSpecifier: {
CXXBaseSpecifier *BaseSpec = getCursorCXXBaseSpecifier(C);
if (!BaseSpec)
@@ -3768,6 +3828,9 @@
case CXCursor_OverloadedDeclRef:
return getCursorOverloadedDeclRef(C).second;
+ case CXCursor_VariableRef:
+ return getCursorVariableRef(C).second;
+
default:
// FIXME: Need a way to enumerate all non-reference cases.
llvm_unreachable("Missed a reference kind");
@@ -3975,6 +4038,9 @@
case CXCursor_OverloadedDeclRef:
return C;
+
+ case CXCursor_VariableRef:
+ return MakeCXCursor(getCursorVariableRef(C).first, tu);
default:
// We would prefer to enumerate all non-reference cursor kinds here.
Modified: cfe/branches/tooling/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CXCursor.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CXCursor.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CXCursor.cpp Mon Feb 20 19:34:24 2012
@@ -226,7 +226,6 @@
case Stmt::UnaryExprOrTypeTraitExprClass:
case Stmt::UnaryTypeTraitExprClass:
case Stmt::VAArgExprClass:
- case Stmt::LambdaExprClass:
K = CXCursor_UnexposedExpr;
break;
@@ -441,6 +440,10 @@
K = CXCursor_CallExpr;
break;
+ case Stmt::LambdaExprClass:
+ K = CXCursor_LambdaExpr;
+ break;
+
case Stmt::ObjCMessageExprClass: {
K = CXCursor_ObjCMessageExpr;
int SelectorIdIndex = -1;
@@ -573,6 +576,23 @@
reinterpret_cast<uintptr_t>(C.data[1])));
}
+CXCursor cxcursor::MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
+ CXTranslationUnit TU) {
+
+ assert(Var && TU && "Invalid arguments!");
+ void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
+ CXCursor C = { CXCursor_VariableRef, 0, { (void*)Var, RawLoc, TU } };
+ return C;
+}
+
+std::pair<VarDecl *, SourceLocation>
+cxcursor::getCursorVariableRef(CXCursor C) {
+ assert(C.kind == CXCursor_VariableRef);
+ return std::make_pair(static_cast<VarDecl *>(C.data[0]),
+ SourceLocation::getFromRawEncoding(
+ reinterpret_cast<uintptr_t>(C.data[1])));
+}
+
CXCursor cxcursor::MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc,
CXTranslationUnit TU) {
Modified: cfe/branches/tooling/tools/libclang/CXCursor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CXCursor.h?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CXCursor.h (original)
+++ cfe/branches/tooling/tools/libclang/CXCursor.h Mon Feb 20 19:34:24 2012
@@ -41,6 +41,7 @@
class TemplateDecl;
class TemplateName;
class TypeDecl;
+class VarDecl;
namespace cxcursor {
@@ -111,6 +112,14 @@
/// it references and the location where the reference occurred.
std::pair<NamedDecl *, SourceLocation> getCursorNamespaceRef(CXCursor C);
+/// \brief Create a reference to a variable at the given location.
+CXCursor MakeCursorVariableRef(const VarDecl *Var, SourceLocation Loc,
+ CXTranslationUnit TU);
+
+/// \brief Unpack a VariableRef cursor into the variable it references and the
+/// location where the where the reference occurred.
+std::pair<VarDecl *, SourceLocation> getCursorVariableRef(CXCursor C);
+
/// \brief Create a reference to a field at the given location.
CXCursor MakeCursorMemberRef(const FieldDecl *Field, SourceLocation Loc,
CXTranslationUnit TU);
Modified: cfe/branches/tooling/tools/libclang/CXType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CXType.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CXType.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CXType.cpp Mon Feb 20 19:34:24 2012
@@ -160,12 +160,17 @@
case CXCursor_CXXBaseSpecifier:
return cxtype::MakeCXType(getCursorCXXBaseSpecifier(C)->getType(), TU);
-
- case CXCursor_ObjCProtocolRef:
+
+ case CXCursor_MemberRef:
+ return cxtype::MakeCXType(getCursorMemberRef(C).first->getType(), TU);
+
+ case CXCursor_VariableRef:
+ return cxtype::MakeCXType(getCursorVariableRef(C).first->getType(), TU);
+
+ case CXCursor_ObjCProtocolRef:
case CXCursor_TemplateRef:
case CXCursor_NamespaceRef:
- case CXCursor_MemberRef:
- case CXCursor_OverloadedDeclRef:
+ case CXCursor_OverloadedDeclRef:
default:
break;
}
Modified: cfe/branches/tooling/tools/libclang/CursorVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CursorVisitor.h?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CursorVisitor.h (original)
+++ cfe/branches/tooling/tools/libclang/CursorVisitor.h Mon Feb 20 19:34:24 2012
@@ -31,7 +31,8 @@
ExplicitTemplateArgsVisitKind,
NestedNameSpecifierLocVisitKind,
DeclarationNameInfoVisitKind,
- MemberRefVisitKind, SizeOfPackExprPartsKind };
+ MemberRefVisitKind, SizeOfPackExprPartsKind,
+ LambdaExprPartsKind };
protected:
void *data[3];
CXCursor parent;
Modified: cfe/branches/tooling/tools/libclang/IndexBody.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexBody.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexBody.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexBody.cpp Mon Feb 20 19:34:24 2012
@@ -97,10 +97,21 @@
}
bool VisitDeclStmt(DeclStmt *S) {
- if (IndexCtx.indexFunctionLocalSymbols())
+ if (IndexCtx.shouldIndexFunctionLocalSymbols())
IndexCtx.indexDeclGroupRef(S->getDeclGroup());
return true;
}
+
+ bool TraverseLambdaCapture(LambdaExpr::Capture C) {
+ if (C.capturesThis())
+ return true;
+
+ if (IndexCtx.shouldIndexFunctionLocalSymbols())
+ IndexCtx.handleReference(C.getCapturedVar(), C.getLocation(),
+ Parent, ParentDC);
+ return true;
+ }
+
};
} // anonymous namespace
Modified: cfe/branches/tooling/tools/libclang/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexDecl.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexDecl.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexDecl.cpp Mon Feb 20 19:34:24 2012
@@ -26,7 +26,7 @@
void handleDeclarator(DeclaratorDecl *D, const NamedDecl *Parent = 0) {
if (!Parent) Parent = D;
- if (!IndexCtx.indexFunctionLocalSymbols()) {
+ if (!IndexCtx.shouldIndexFunctionLocalSymbols()) {
IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), Parent);
IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
} else {
@@ -245,9 +245,11 @@
bool VisitClassTemplateSpecializationDecl(
ClassTemplateSpecializationDecl *D) {
- // FIXME: Notify subsequent callbacks that info comes from implicit
+ // FIXME: Notify subsequent callbacks if info comes from implicit
// instantiation.
- if (D->isThisDeclarationADefinition())
+ if (D->isThisDeclarationADefinition() &&
+ (IndexCtx.shouldIndexImplicitTemplateInsts() ||
+ !IndexCtx.isTemplateImplicitInstantiation(D)))
IndexCtx.indexTagDecl(D);
return true;
}
Modified: cfe/branches/tooling/tools/libclang/IndexTypeSourceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexTypeSourceInfo.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexTypeSourceInfo.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexTypeSourceInfo.cpp Mon Feb 20 19:34:24 2012
@@ -73,12 +73,23 @@
bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
if (const TemplateSpecializationType *T = TL.getTypePtr()) {
- if (CXXRecordDecl *RD = T->getAsCXXRecordDecl())
- IndexCtx.handleReference(RD, TL.getTemplateNameLoc(),
- Parent, ParentDC);
+ if (IndexCtx.shouldIndexImplicitTemplateInsts()) {
+ if (CXXRecordDecl *RD = T->getAsCXXRecordDecl())
+ IndexCtx.handleReference(RD, TL.getTemplateNameLoc(),
+ Parent, ParentDC);
+ } else {
+ if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
+ IndexCtx.handleReference(D, TL.getTemplateNameLoc(),
+ Parent, ParentDC);
+ }
}
return true;
}
+
+ bool TraverseStmt(Stmt *S) {
+ IndexCtx.indexBody(S, Parent, ParentDC);
+ return true;
+ }
};
} // anonymous namespace
Modified: cfe/branches/tooling/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/Indexing.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/Indexing.cpp (original)
+++ cfe/branches/tooling/tools/libclang/Indexing.cpp Mon Feb 20 19:34:24 2012
@@ -137,11 +137,17 @@
virtual void HandleInterestingDecl(DeclGroupRef D) {}
virtual void HandleTagDeclDefinition(TagDecl *D) {
+ if (!IndexCtx.shouldIndexImplicitTemplateInsts())
+ return;
+
if (IndexCtx.isTemplateImplicitInstantiation(D))
IndexCtx.indexDecl(D);
}
virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D) {
+ if (!IndexCtx.shouldIndexImplicitTemplateInsts())
+ return;
+
IndexCtx.indexDecl(D);
}
};
@@ -194,7 +200,12 @@
indexDiagnostics(CXTU, IndexCtx);
}
- virtual TranslationUnitKind getTranslationUnitKind() { return TU_Complete; }
+ virtual TranslationUnitKind getTranslationUnitKind() {
+ if (IndexCtx.shouldIndexImplicitTemplateInsts())
+ return TU_Complete;
+ else
+ return TU_Prefix;
+ }
virtual bool hasCodeCompletionSupport() const { return false; }
};
Modified: cfe/branches/tooling/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexingContext.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexingContext.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexingContext.cpp Mon Feb 20 19:34:24 2012
@@ -35,7 +35,7 @@
IdxCtx.getIndexLoc(Loc) };
ProtInfos.push_back(ProtInfo);
- if (IdxCtx.suppressRefs())
+ if (IdxCtx.shouldSuppressRefs())
IdxCtx.markEntityOccurrenceInFile(PD, Loc);
}
@@ -265,11 +265,11 @@
ScratchAlloc SA(*this);
getEntityInfo(D, DInfo.EntInfo, SA);
- if ((!indexFunctionLocalSymbols() && !DInfo.EntInfo.USR)
+ if ((!shouldIndexFunctionLocalSymbols() && !DInfo.EntInfo.USR)
|| Loc.isInvalid())
return false;
- if (suppressRefs())
+ if (shouldSuppressRefs())
markEntityOccurrenceInFile(D, Loc);
DInfo.entityInfo = &DInfo.EntInfo;
@@ -357,7 +357,7 @@
bool IndexingContext::handleObjCInterface(const ObjCInterfaceDecl *D) {
// For @class forward declarations, suppress them the same way as references.
if (!D->isThisDeclarationADefinition()) {
- if (suppressRefs() && markEntityOccurrenceInFile(D, D->getLocation()))
+ if (shouldSuppressRefs() && markEntityOccurrenceInFile(D, D->getLocation()))
return false; // already occurred.
// FIXME: This seems like the wrong definition for redeclaration.
@@ -382,7 +382,7 @@
BaseClass.cursor = MakeCursorObjCSuperClassRef(SuperD, SuperLoc, CXTU);
BaseClass.loc = getIndexLoc(SuperLoc);
- if (suppressRefs())
+ if (shouldSuppressRefs())
markEntityOccurrenceInFile(SuperD, SuperLoc);
}
@@ -411,7 +411,7 @@
bool IndexingContext::handleObjCProtocol(const ObjCProtocolDecl *D) {
if (!D->isThisDeclarationADefinition()) {
- if (suppressRefs() && markEntityOccurrenceInFile(D, D->getLocation()))
+ if (shouldSuppressRefs() && markEntityOccurrenceInFile(D, D->getLocation()))
return false; // already occurred.
// FIXME: This seems like the wrong definition for redeclaration.
@@ -448,7 +448,7 @@
: D->getCategoryNameLoc();
getEntityInfo(IFaceD, ClassEntity, SA);
- if (suppressRefs())
+ if (shouldSuppressRefs())
markEntityOccurrenceInFile(IFaceD, ClassLoc);
ObjCProtocolListInfo ProtInfo(D->getReferencedProtocols(), *this, SA);
@@ -479,7 +479,7 @@
SourceLocation CategoryLoc = D->getCategoryNameLoc();
getEntityInfo(IFaceD, ClassEntity, SA);
- if (suppressRefs())
+ if (shouldSuppressRefs())
markEntityOccurrenceInFile(IFaceD, ClassLoc);
CatDInfo.ObjCCatDeclInfo.containerInfo = &CatDInfo.ObjCContDeclInfo;
@@ -573,14 +573,14 @@
return false;
if (Loc.isInvalid())
return false;
- if (!indexFunctionLocalSymbols() && D->getParentFunctionOrMethod())
+ if (!shouldIndexFunctionLocalSymbols() && D->getParentFunctionOrMethod())
return false;
if (isNotFromSourceFile(D->getLocation()))
return false;
if (D->isImplicit() && shouldIgnoreIfImplicit(D))
return false;
- if (suppressRefs()) {
+ if (shouldSuppressRefs()) {
if (markEntityOccurrenceInFile(D, Loc))
return false; // already occurred.
}
@@ -660,7 +660,7 @@
CXXDInfo.CXXClassInfo.bases = BaseList.getBases();
CXXDInfo.CXXClassInfo.numBases = BaseList.getNumBases();
- if (suppressRefs()) {
+ if (shouldSuppressRefs()) {
// Go through bases and mark them as referenced.
for (unsigned i = 0, e = BaseList.getNumBases(); i != e; ++i) {
const CXIdxBaseClassInfo *baseInfo = BaseList.getBases()[i];
@@ -1035,7 +1035,9 @@
return MakeCursorNamespaceRef(Namespace, Loc, CXTU);
if (const FieldDecl *Field = dyn_cast<FieldDecl>(D))
return MakeCursorMemberRef(Field, Loc, CXTU);
-
+ if (const VarDecl *Var = dyn_cast<VarDecl>(D))
+ return MakeCursorVariableRef(Var, Loc, CXTU);
+
return clang_getNullCursor();
}
Modified: cfe/branches/tooling/tools/libclang/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexingContext.h?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexingContext.h (original)
+++ cfe/branches/tooling/tools/libclang/IndexingContext.h Mon Feb 20 19:34:24 2012
@@ -322,14 +322,18 @@
void setASTContext(ASTContext &ctx);
void setPreprocessor(Preprocessor &PP);
- bool suppressRefs() const {
+ bool shouldSuppressRefs() const {
return IndexOptions & CXIndexOpt_SuppressRedundantRefs;
}
- bool indexFunctionLocalSymbols() const {
+ bool shouldIndexFunctionLocalSymbols() const {
return IndexOptions & CXIndexOpt_IndexFunctionLocalSymbols;
}
+ bool shouldIndexImplicitTemplateInsts() const {
+ return IndexOptions & CXIndexOpt_IndexImplicitTemplateInstantiations;
+ }
+
bool shouldAbort();
bool hasDiagnosticCallback() const { return CB.diagnostic; }
Modified: cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/branches/tooling/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Feb 20 19:34:24 2012
@@ -1221,8 +1221,8 @@
}
TEST(Matcher, NewExpressionArgument) {
- StatementMatcher New = Expression(NewExpression(
- HasConstructorArgument(
+ StatementMatcher New = Expression(ConstructorCall(
+ HasArgument(
0, DeclarationReference(To(Variable(HasName("y")))))));
EXPECT_TRUE(
@@ -1235,8 +1235,8 @@
NotMatches("class X { public: X(int); }; void x() { int z; new X(z); }",
New));
- StatementMatcher WrongIndex = Expression(NewExpression(
- HasConstructorArgument(
+ StatementMatcher WrongIndex = Expression(ConstructorCall(
+ HasArgument(
42, DeclarationReference(To(Variable(HasName("y")))))));
EXPECT_TRUE(
NotMatches("class X { public: X(int); }; void x() { int y; new X(y); }",
@@ -1244,8 +1244,7 @@
}
TEST(Matcher, NewExpressionArgumentCount) {
- StatementMatcher New = Expression(NewExpression(
- ConstructorArgumentCountIs(1)));
+ StatementMatcher New = ConstructorCall(ArgumentCountIs(1));
EXPECT_TRUE(
Matches("class X { public: X(int); }; void x() { new X(0); }", New));
Modified: cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp Mon Feb 20 19:34:24 2012
@@ -21,6 +21,7 @@
#include <map>
#include <algorithm>
#include <functional>
+#include <set>
using namespace llvm;
//===----------------------------------------------------------------------===//
@@ -138,7 +139,21 @@
const std::vector<Record*> &Diags =
Records.getAllDerivedDefinitions("Diagnostic");
-
+
+ // Make a sorted set of all warning opts so we can get the index.
+ std::set<std::string> WarningOpts;
+ for (unsigned i = 0, e = Diags.size(); i != e; ++i) {
+ const Record *R = Diags[i];
+ DefInit *DI = dynamic_cast<DefInit*>(R->getValueInit("Group"));
+ if (DI)
+ WarningOpts.insert(DI->getDef()->getValueAsString("GroupName"));
+ }
+
+ std::vector<Record*> DiagGroups
+ = Records.getAllDerivedDefinitions("DiagGroup");
+ for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i)
+ WarningOpts.insert(DiagGroups[i]->getValueAsString("GroupName"));
+
DiagCategoryIDMap CategoryIDs(Records);
DiagGroupParentMap DGParentMap(Records);
@@ -156,12 +171,15 @@
OS << ", \"";
OS.write_escaped(R.getValueAsString("Text")) << '"';
- // Warning associated with the diagnostic.
+ // Warning associated with the diagnostic. This is stored as an index into
+ // the alphabetically sorted warning table.
if (DefInit *DI = dynamic_cast<DefInit*>(R.getValueInit("Group"))) {
- OS << ", \"";
- OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"';
+ std::set<std::string>::iterator I =
+ WarningOpts.find(DI->getDef()->getValueAsString("GroupName"));
+ assert(I != WarningOpts.end());
+ OS << ", " << std::distance(WarningOpts.begin(), I);
} else {
- OS << ", \"\"";
+ OS << ", 0";
}
// SFINAE bit
Modified: cfe/branches/tooling/utils/analyzer/SATestBuild.py
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/analyzer/SATestBuild.py?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/utils/analyzer/SATestBuild.py (original)
+++ cfe/branches/tooling/utils/analyzer/SATestBuild.py Mon Feb 20 19:34:24 2012
@@ -72,7 +72,7 @@
# The list of checkers used during analyzes.
# Currently, consists of all the non experimental checkers.
-Checkers="experimental.security.taint,core,deadcode,cplusplus,security,unix,osx,cocoa,experimental.osx.cocoa.Containers,experimental.unix.cstring.BadSizeArg"
+Checkers="experimental.security.taint,core,deadcode,cplusplus,security,unix,osx,cocoa,experimental.osx.cocoa.Containers,experimental.unix.cstring.BadSizeArg,experimental.unix.Malloc"
Verbose = 1
Modified: cfe/branches/tooling/www/cxx_status.html
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/www/cxx_status.html?rev=151016&r1=151015&r2=151016&view=diff
==============================================================================
--- cfe/branches/tooling/www/cxx_status.html (original)
+++ cfe/branches/tooling/www/cxx_status.html Mon Feb 20 19:34:24 2012
@@ -8,7 +8,7 @@
<link type="text/css" rel="stylesheet" href="content.css">
<style type="text/css">
.none { background-color: #FFCCCC }
- .partial { background-color: #FFFF99 }
+ .svn { background-color: #FFFF99 }
.full { background-color: #CCFF99 }
th { background-color: #FFDDAA }
</style>
@@ -166,7 +166,7 @@
<tr>
<td>Generalized constant expressions</td>
<td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf">N2235</a></td>
- <td class="none" align="center">No</td>
+ <td class="svn" align="center">SVN</td>
</tr>
<tr>
<td>Alignment support</td>
More information about the llvm-branch-commits
mailing list