[llvm-branch-commits] [cfe-branch] r156378 [2/2] - in /cfe/branches/tooling: ./ bindings/python/clang/ bindings/python/tests/cindex/ docs/ examples/ include/clang-c/ include/clang/AST/ include/clang/Analysis/ include/clang/Analysis/Analyses/ include/clang/Basic/ include/clang/Driver/ include/clang/Frontend/ include/clang/Lex/ include/clang/Parse/ include/clang/Rewrite/ include/clang/Sema/ include/clang/Serialization/ include/clang/StaticAnalyzer/Core/PathSensitive/ include/clang/Tooling/ lib/ARCMigrate/ lib/AST/ lib/Analysis/...
Manuel Klimek
klimek at google.com
Tue May 8 01:47:33 PDT 2012
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Core/SymbolManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Core/SymbolManager.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Core/SymbolManager.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Core/SymbolManager.cpp Tue May 8 03:47:31 2012
@@ -164,6 +164,13 @@
llvm_unreachable("unhandled expansion case");
}
+unsigned SymExpr::computeComplexity() const {
+ unsigned R = 0;
+ for (symbol_iterator I = symbol_begin(), E = symbol_end(); I != E; ++I)
+ R++;
+ return R;
+}
+
const SymbolRegionValue*
SymbolManager::getRegionValueSymbol(const TypedValueRegion* R) {
llvm::FoldingSetNodeID profile;
Modified: cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/branches/tooling/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Tue May 8 03:47:31 2012
@@ -102,7 +102,7 @@
/// The local declaration to all declarations ratio might be very small when
/// working with a PCH file.
SetOfDecls LocalTUDecls;
-
+
// PD is owned by AnalysisManager.
PathDiagnosticConsumer *PD;
@@ -306,7 +306,7 @@
if (isa<ObjCMethodDecl>(*I))
continue;
- LocalTUDecls.insert(*I);
+ LocalTUDecls.push_back(*I);
}
}
@@ -338,11 +338,11 @@
// translation unit. This step is very important for performance. It ensures
// that we analyze the root functions before the externally available
// subroutines.
- std::queue<CallGraphNode*> BFSQueue;
+ std::deque<CallGraphNode*> BFSQueue;
for (llvm::SmallVector<CallGraphNode*, 24>::reverse_iterator
TI = TopLevelFunctions.rbegin(), TE = TopLevelFunctions.rend();
TI != TE; ++TI)
- BFSQueue.push(*TI);
+ BFSQueue.push_front(*TI);
// BFS over all of the functions, while skipping the ones inlined into
// the previously processed functions. Use external Visited set, which is
@@ -350,7 +350,7 @@
SmallPtrSet<CallGraphNode*,24> Visited;
while(!BFSQueue.empty()) {
CallGraphNode *N = BFSQueue.front();
- BFSQueue.pop();
+ BFSQueue.pop_front();
// Skip the functions which have been processed already or previously
// inlined.
@@ -365,8 +365,8 @@
(Mgr->InliningMode == All ? 0 : &VisitedCallees));
// Add the visited callees to the global visited set.
- for (SetOfConstDecls::const_iterator I = VisitedCallees.begin(),
- E = VisitedCallees.end(); I != E; ++I){
+ for (SetOfConstDecls::iterator I = VisitedCallees.begin(),
+ E = VisitedCallees.end(); I != E; ++I) {
CallGraphNode *VN = CG.getNode(*I);
if (VN)
Visited.insert(VN);
@@ -376,7 +376,7 @@
// Push the children into the queue.
for (CallGraphNode::const_iterator CI = N->begin(),
CE = N->end(); CI != CE; ++CI) {
- BFSQueue.push(*CI);
+ BFSQueue.push_front(*CI);
}
}
}
@@ -402,9 +402,15 @@
RecVisitorBR = &BR;
// Process all the top level declarations.
- for (SetOfDecls::iterator I = LocalTUDecls.begin(),
- E = LocalTUDecls.end(); I != E; ++I)
- TraverseDecl(*I);
+ //
+ // Note: TraverseDecl may modify LocalTUDecls, but only by appending more
+ // entries. Thus we don't use an iterator, but rely on LocalTUDecls
+ // random access. By doing so, we automatically compensate for iterators
+ // possibly being invalidated, although this is a bit slower.
+ const unsigned n = LocalTUDecls.size();
+ for (unsigned i = 0 ; i < n ; ++i) {
+ TraverseDecl(LocalTUDecls[i]);
+ }
if (Mgr->shouldInlineCall())
HandleDeclsGallGraph();
@@ -520,7 +526,7 @@
}
// Execute the worklist algorithm.
- Eng.ExecuteWorkList(Mgr->getAnalysisDeclContextManager().getStackFrame(D, 0),
+ Eng.ExecuteWorkList(Mgr->getAnalysisDeclContextManager().getStackFrame(D),
Mgr->getMaxNodes());
// Release the auditor (if any) so that it doesn't monitor the graph
Modified: cfe/branches/tooling/lib/Tooling/Tooling.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/lib/Tooling/Tooling.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/lib/Tooling/Tooling.cpp (original)
+++ cfe/branches/tooling/lib/Tooling/Tooling.cpp Tue May 8 03:47:31 2012
@@ -26,6 +26,13 @@
#include "llvm/Support/Host.h"
#include "llvm/Support/raw_ostream.h"
+// For chdir, see the comment in ClangTool::run for more information.
+#ifdef _WIN32
+# include <direct.h>
+#else
+# include <unistd.h>
+#endif
+
namespace clang {
namespace tooling {
@@ -256,18 +263,12 @@
llvm::SmallString<1024> File(getAbsolutePath(
SourcePaths[I], BaseDirectory));
- std::vector<CompileCommand> CompileCommands =
+ std::vector<CompileCommand> CompileCommandsForFile =
Compilations.getCompileCommands(File.str());
- if (!CompileCommands.empty()) {
- for (int I = 0, E = CompileCommands.size(); I != E; ++I) {
- CompileCommand &Command = CompileCommands[I];
- if (!Command.Directory.empty()) {
- // FIXME: What should happen if CommandLine includes -working-directory
- // as well?
- Command.CommandLine.push_back(
- "-working-directory=" + Command.Directory);
- }
- CommandLines.push_back(std::make_pair(File.str(), Command.CommandLine));
+ if (!CompileCommandsForFile.empty()) {
+ for (int I = 0, E = CompileCommandsForFile.size(); I != E; ++I) {
+ CompileCommands.push_back(std::make_pair(File.str(),
+ CompileCommandsForFile[I]));
}
} else {
// FIXME: There are two use cases here: doing a fuzzy
@@ -286,9 +287,20 @@
int ClangTool::run(FrontendActionFactory *ActionFactory) {
bool ProcessingFailed = false;
- for (unsigned I = 0; I < CommandLines.size(); ++I) {
- std::string File = CommandLines[I].first;
- std::vector<std::string> &CommandLine = CommandLines[I].second;
+ for (unsigned I = 0; I < CompileCommands.size(); ++I) {
+ std::string File = CompileCommands[I].first;
+ // FIXME: chdir is thread hostile; on the other hand, creating the same
+ // behavior as chdir is complex: chdir resolves the path once, thus
+ // guaranteeing that all subsequent relative path operations work
+ // on the same path the original chdir resulted in. This makes a difference
+ // for example on network filesystems, where symlinks might be switched
+ // during runtime of the tool. Fixing this depends on having a file system
+ // abstraction that allows openat() style interactions.
+ if (chdir(CompileCommands[I].second.Directory.c_str()))
+ llvm::report_fatal_error("Cannot chdir into \"" +
+ CompileCommands[I].second.Directory + "\n!");
+ std::vector<std::string> &CommandLine =
+ CompileCommands[I].second.CommandLine;
llvm::outs() << "Processing: " << File << ".\n";
ToolInvocation Invocation(CommandLine, ActionFactory->create(), &Files);
for (int I = 0, E = MappedFileContents.size(); I != E; ++I) {
Modified: cfe/branches/tooling/test/Analysis/additive-folding-range-constraints.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/additive-folding-range-constraints.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/additive-folding-range-constraints.c (original)
+++ cfe/branches/tooling/test/Analysis/additive-folding-range-constraints.c Tue May 8 03:47:31 2012
@@ -1,17 +1,20 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -verify -analyzer-constraints=range %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=range %s
// These are used to trigger warnings.
typedef typeof(sizeof(int)) size_t;
void *malloc(size_t);
void free(void *);
#define NULL ((void*)0)
-#define UINT_MAX (__INT_MAX__ *2U +1U)
+#define UINT_MAX (~0U)
+#define INT_MAX (UINT_MAX & (UINT_MAX >> 1))
+#define INT_MIN (-INT_MAX - 1)
+
// Each of these adjusted ranges has an adjustment small enough to split the
// solution range across an overflow boundary (Min for <, Max for >).
// This corresponds to one set of branches in RangeConstraintManager.
void smallAdjustmentGT (unsigned a) {
- char* b = NULL;
+ void *b = NULL;
if (a+2 > 1)
b = malloc(1);
if (a == UINT_MAX-1 || a == UINT_MAX)
@@ -22,7 +25,7 @@
}
void smallAdjustmentGE (unsigned a) {
- char* b = NULL;
+ void *b = NULL;
if (a+2 >= 1)
b = malloc(1);
if (a == UINT_MAX-1)
@@ -33,7 +36,7 @@
}
void smallAdjustmentLT (unsigned a) {
- char* b = NULL;
+ void *b = NULL;
if (a+1 < 2)
b = malloc(1);
if (a == 0 || a == UINT_MAX)
@@ -42,7 +45,7 @@
}
void smallAdjustmentLE (unsigned a) {
- char* b = NULL;
+ void *b = NULL;
if (a+1 <= 2)
b = malloc(1);
if (a == 0 || a == 1 || a == UINT_MAX)
@@ -55,7 +58,7 @@
// comparison value over an overflow boundary (Min for <, Max for >).
// This corresponds to one set of branches in RangeConstraintManager.
void largeAdjustmentGT (unsigned a) {
- char* b = NULL;
+ void *b = NULL;
if (a-2 > UINT_MAX-1)
b = malloc(1);
if (a == 1 || a == 0)
@@ -66,7 +69,7 @@
}
void largeAdjustmentGE (unsigned a) {
- char* b = NULL;
+ void *b = NULL;
if (a-2 >= UINT_MAX-1)
b = malloc(1);
if (a > 1)
@@ -77,7 +80,7 @@
}
void largeAdjustmentLT (unsigned a) {
- char* b = NULL;
+ void *b = NULL;
if (a+2 < 1)
b = malloc(1);
if (a == UINT_MAX-1 || a == UINT_MAX)
@@ -88,7 +91,7 @@
}
void largeAdjustmentLE (unsigned a) {
- char* b = NULL;
+ void *b = NULL;
if (a+2 <= 1)
b = malloc(1);
if (a < UINT_MAX-1)
@@ -97,3 +100,158 @@
free(b);
return; // no-warning
}
+
+
+// Test the nine cases in RangeConstraintManager's pinning logic.
+void mixedComparisons1(signed char a) {
+ // Case 1: The range is entirely below the symbol's range.
+ int min = INT_MIN;
+
+ if ((a - 2) < (min + 5LL))
+ return; // expected-warning{{never executed}}
+
+ if (a == 0)
+ return; // no-warning
+ if (a == 0x7F)
+ return; // no-warning
+ if (a == -0x80)
+ return; // no-warning
+ return; // no-warning
+}
+
+void mixedComparisons2(signed char a) {
+ // Case 2: Only the lower end of the range is outside.
+ if ((a - 5) < (-0x81LL)) {
+ if (a == 0)
+ return; // expected-warning{{never executed}}
+ if (a == 0x7F)
+ return; // expected-warning{{never executed}}
+ if (a == -0x80)
+ return; // no-warning
+ return; // no-warning
+ } else {
+ return; // no-warning
+ }
+}
+
+void mixedComparisons3(signed char a) {
+ // Case 3: The entire symbol range is covered.
+ if ((a - 0x200) < -0x100LL) {
+ if (a == 0)
+ return; // no-warning
+ if (a == 0x7F)
+ return; // no-warning
+ if (a == -0x80)
+ return; // no-warning
+ return; // no-warning
+ } else {
+ return; // expected-warning{{never executed}}
+ }
+}
+
+void mixedComparisons4(signed char a) {
+ // Case 4: The range wraps around, but the lower wrap is out-of-range.
+ if ((a - 5) > 0LL) {
+ if (a == 0)
+ return; // expected-warning{{never executed}}
+ if (a == 0x7F)
+ return; // no-warning
+ if (a == -0x80)
+ return; // expected-warning{{never executed}}
+ return; // no-warning
+ } else {
+ return; // no-warning
+ }
+}
+
+void mixedComparisons5(signed char a) {
+ // Case 5a: The range is inside and does not wrap.
+ if ((a + 5) == 0LL) {
+ if (a == 0)
+ return; // expected-warning{{never executed}}
+ if (a == 0x7F)
+ return; // expected-warning{{never executed}}
+ if (a == -0x80)
+ return; // expected-warning{{never executed}}
+ return; // no-warning
+ } else {
+ return; // no-warning
+ }
+}
+
+void mixedComparisons5Wrap(signed char a) {
+ // Case 5b: The range is inside and does wrap.
+ if ((a + 5) != 0LL) {
+ if (a == 0)
+ return; // no-warning
+ if (a == 0x7F)
+ return; // no-warning
+ if (a == -0x80)
+ return; // no-warning
+ return; // no-warning
+ } else {
+ return; // no-warning
+ }
+}
+
+void mixedComparisons6(signed char a) {
+ // Case 6: Only the upper end of the range is outside.
+ if ((a + 5) > 0x81LL) {
+ if (a == 0)
+ return; // expected-warning{{never executed}}
+ if (a == 0x7F)
+ return; // no-warning
+ if (a == -0x80)
+ return; // expected-warning{{never executed}}
+ return; // no-warning
+ } else {
+ return; // no-warning
+ }
+}
+
+void mixedComparisons7(signed char a) {
+ // Case 7: The range wraps around but is entirely outside the symbol's range.
+ int min = INT_MIN;
+
+ if ((a + 2) < (min + 5LL))
+ return; // expected-warning{{never executed}}
+
+ if (a == 0)
+ return; // no-warning
+ if (a == 0x7F)
+ return; // no-warning
+ if (a == -0x80)
+ return; // no-warning
+ return; // no-warning
+}
+
+void mixedComparisons8(signed char a) {
+ // Case 8: The range wraps, but the upper wrap is out of range.
+ if ((a + 5) < 0LL) {
+ if (a == 0)
+ return; // expected-warning{{never executed}}
+ if (a == 0x7F)
+ return; // expected-warning{{never executed}}
+ if (a == -0x80)
+ return; // no-warning
+ return; // no-warning
+ } else {
+ return; // no-warning
+ }
+}
+
+void mixedComparisons9(signed char a) {
+ // Case 9: The range is entirely above the symbol's range.
+ int max = INT_MAX;
+
+ if ((a + 2) > (max - 5LL))
+ return; // expected-warning{{never executed}}
+
+ if (a == 0)
+ return; // no-warning
+ if (a == 0x7F)
+ return; // no-warning
+ if (a == -0x80)
+ return; // no-warning
+ return; // no-warning
+}
Removed: cfe/branches/tooling/test/Analysis/additive-folding.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/additive-folding.c?rev=156377&view=auto
==============================================================================
--- cfe/branches/tooling/test/Analysis/additive-folding.c (original)
+++ cfe/branches/tooling/test/Analysis/additive-folding.c (removed)
@@ -1,203 +0,0 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=basic %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=range %s
-
-// These are used to trigger warnings.
-typedef typeof(sizeof(int)) size_t;
-void *malloc(size_t);
-void free(void *);
-#define NULL ((void*)0)
-#define UINT_MAX -1U
-
-//---------------
-// Plus/minus
-//---------------
-
-void separateExpressions (int a) {
- int b = a + 1;
- --b;
-
- char* buf = malloc(1);
- if (a != 0 && b == 0)
- return; // expected-warning{{never executed}}
- free(buf);
-}
-
-void oneLongExpression (int a) {
- // Expression canonicalization should still allow this to work, even though
- // the first term is on the left.
- int b = 15 + a + 15 - 10 - 20;
-
- char* buf = malloc(1);
- if (a != 0 && b == 0)
- return; // expected-warning{{never executed}}
- free(buf);
-}
-
-void mixedTypes (int a) {
- char* buf = malloc(1);
-
- // Different additive types should not cause crashes when constant-folding.
- // This is part of PR7406.
- int b = a + 1LL;
- if (a != 0 && (b-1) == 0) // not crash
- return; // expected-warning{{never executed}}
-
- int c = a + 1U;
- if (a != 0 && (c-1) == 0) // not crash
- return; // expected-warning{{never executed}}
-
- free(buf);
-}
-
-//---------------
-// Comparisons
-//---------------
-
-// Equality and inequality only
-void eq_ne (unsigned a) {
- char* b = NULL;
- if (a == UINT_MAX)
- b = malloc(1);
- if (a+1 != 0)
- return; // no-warning
- if (a-1 != UINT_MAX-1)
- return; // no-warning
- free(b);
-}
-
-void ne_eq (unsigned a) {
- char* b = NULL;
- if (a != UINT_MAX)
- b = malloc(1);
- if (a+1 == 0)
- return; // no-warning
- if (a-1 == UINT_MAX-1)
- return; // no-warning
- free(b);
-}
-
-// Mixed typed inequalities (part of PR7406)
-// These should not crash.
-void mixed_eq_ne (int a) {
- char* b = NULL;
- if (a == 1)
- b = malloc(1);
- if (a+1U != 2)
- return; // no-warning
- if (a-1U != 0)
- return; // expected-warning{{never executed}}
- free(b);
-}
-
-void mixed_ne_eq (int a) {
- char* b = NULL;
- if (a != 1)
- b = malloc(1);
- if (a+1U == 2)
- return; // no-warning
- if (a-1U == 0)
- return; // expected-warning{{never executed}}
- free(b);
-}
-
-
-// Simple order comparisons with no adjustment
-void baselineGT (unsigned a) {
- char* b = NULL;
- if (a > 0)
- b = malloc(1);
- if (a == 0)
- return; // no-warning
- free(b);
-}
-
-void baselineGE (unsigned a) {
- char* b = NULL;
- if (a >= UINT_MAX)
- b = malloc(1);
- if (a == UINT_MAX)
- free(b);
- return; // no-warning
-}
-
-void baselineLT (unsigned a) {
- char* b = NULL;
- if (a < UINT_MAX)
- b = malloc(1);
- if (a == UINT_MAX)
- return; // no-warning
- free(b);
-}
-
-void baselineLE (unsigned a) {
- char* b = NULL;
- if (a <= 0)
- b = malloc(1);
- if (a == 0)
- free(b);
- return; // no-warning
-}
-
-
-// Adjustment gives each of these an extra solution!
-void adjustedGT (unsigned a) {
- char* b = NULL;
- if (a-1 > UINT_MAX-1)
- b = malloc(1);
- return; // expected-warning{{leak}}
-}
-
-void adjustedGE (unsigned a) {
- char* b = NULL;
- if (a-1 >= UINT_MAX-1)
- b = malloc(1);
- if (a == UINT_MAX)
- free(b);
- return; // expected-warning{{leak}}
-}
-
-void adjustedLT (unsigned a) {
- char* b = NULL;
- if (a+1 < 1)
- b = malloc(1);
- return; // expected-warning{{leak}}
-}
-
-void adjustedLE (unsigned a) {
- char* b = NULL;
- if (a+1 <= 1)
- b = malloc(1);
- if (a == 0)
- free(b);
- return; // expected-warning{{leak}}
-}
-
-
-// Tautologies
-void tautologyGT (unsigned a) {
- char* b = malloc(1);
- if (a > UINT_MAX)
- return; // no-warning
- free(b);
-}
-
-void tautologyGE (unsigned a) {
- char* b = malloc(1);
- if (a >= 0) // expected-warning{{always true}}
- free(b);
- return; // no-warning
-}
-
-void tautologyLT (unsigned a) {
- char* b = malloc(1);
- if (a < 0) // expected-warning{{always false}}
- return; // expected-warning{{never executed}}
- free(b);
-}
-
-void tautologyLE (unsigned a) {
- char* b = malloc(1);
- if (a <= UINT_MAX)
- free(b);
- return; // no-warning
-}
Modified: cfe/branches/tooling/test/Analysis/bstring.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/bstring.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/bstring.c (original)
+++ cfe/branches/tooling/test/Analysis/bstring.c Tue May 8 03:47:31 2012
@@ -428,3 +428,13 @@
bcopy(src, dst, 4); // expected-warning{{overflow}}
}
+
+void *malloc(size_t);
+void free(void *);
+char radar_11125445_memcopythenlogfirstbyte(const char *input, size_t length) {
+ char *bytes = malloc(sizeof(char) * (length + 1));
+ memcpy(bytes, input, length);
+ char x = bytes[0]; // no warning
+ free(bytes);
+ return x;
+}
Modified: cfe/branches/tooling/test/Analysis/constant-folding.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/constant-folding.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/constant-folding.c (original)
+++ cfe/branches/tooling/test/Analysis/constant-folding.c Tue May 8 03:47:31 2012
@@ -70,3 +70,12 @@
if (b<a) WARN; // expected-warning{{never executed}}
if (b-a) WARN; // expected-warning{{never executed}}
}
+
+void testMixedTypeComparisons (char a, unsigned long b) {
+ if (a != 0) return;
+ if (b != 0x100) return;
+
+ if (a > b) WARN; // expected-warning{{never executed}}
+ if (b < a) WARN; // expected-warning{{never executed}}
+ if (a == b) WARN; // expected-warning{{never executed}}
+}
Modified: cfe/branches/tooling/test/Analysis/inline-plist.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/inline-plist.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/inline-plist.c (original)
+++ cfe/branches/tooling/test/Analysis/inline-plist.c Tue May 8 03:47:31 2012
@@ -23,6 +23,19 @@
has_bug(0);
}
+void triggers_bug(int *p) {
+ *p = 0xDEADBEEF;
+}
+
+// This function triggers a bug by calling triggers_bug(). The diagnostics
+// should show when p is assumed to be null.
+void bar(int *p) {
+ if (!!p)
+ return;
+
+ if (p == 0)
+ triggers_bug(p);
+}
// CHECK: <?xml version="1.0" encoding="UTF-8"?>
// CHECK: <plist version="1.0">
@@ -364,6 +377,259 @@
// CHECK: <key>file</key><integer>0</integer>
// CHECK: </dict>
// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>path</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>33</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>33</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>33</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>33</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>33</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>33</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>33</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Assuming 'p' is null</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Assuming 'p' is null</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>33</integer>
+// CHECK: <key>col</key><integer>8</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>33</integer>
+// CHECK: <key>col</key><integer>9</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>36</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>5</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>37</integer>
+// CHECK: <key>col</key><integer>19</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>0</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Calling 'triggers_bug'</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Calling 'triggers_bug'</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Entered call from 'bar'</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Entered call from 'bar'</string>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>control</string>
+// CHECK: <key>edges</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>start</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>26</integer>
+// CHECK: <key>col</key><integer>1</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>end</key>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>kind</key><string>event</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <key>ranges</key>
+// CHECK: <array>
+// CHECK: <array>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>4</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: </array>
+// CHECK: <key>depth</key><integer>1</integer>
+// CHECK: <key>extended_message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string>
+// CHECK: <key>message</key>
+// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string>
+// CHECK: </dict>
+// CHECK: </array>
+// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
+// CHECK: <key>category</key><string>Logic error</string>
+// CHECK: <key>type</key><string>Dereference of null pointer</string>
+// CHECK: <key>issue_context_kind</key><string>function</string>
+// CHECK: <key>issue_context</key><string>triggers_bug</string>
+// CHECK: <key>location</key>
+// CHECK: <dict>
+// CHECK: <key>line</key><integer>27</integer>
+// CHECK: <key>col</key><integer>3</integer>
+// CHECK: <key>file</key><integer>0</integer>
+// CHECK: </dict>
+// CHECK: </dict>
// CHECK: </array>
// CHECK: </dict>
// CHECK: </plist>
Modified: cfe/branches/tooling/test/Analysis/malloc-plist.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc-plist.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc-plist.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc-plist.c Tue May 8 03:47:31 2012
@@ -4054,40 +4054,6 @@
//CHECK: <array>
//CHECK: <dict>
//CHECK: <key>line</key><integer>142</integer>
-//CHECK: <key>col</key><integer>5</integer>
-//CHECK: <key>file</key><integer>0</integer>
-//CHECK: </dict>
-//CHECK: <dict>
-//CHECK: <key>line</key><integer>142</integer>
-//CHECK: <key>col</key><integer>5</integer>
-//CHECK: <key>file</key><integer>0</integer>
-//CHECK: </dict>
-//CHECK: </array>
-//CHECK: </dict>
-//CHECK: </array>
-//CHECK: </dict>
-//CHECK: <dict>
-//CHECK: <key>kind</key><string>control</string>
-//CHECK: <key>edges</key>
-//CHECK: <array>
-//CHECK: <dict>
-//CHECK: <key>start</key>
-//CHECK: <array>
-//CHECK: <dict>
-//CHECK: <key>line</key><integer>142</integer>
-//CHECK: <key>col</key><integer>5</integer>
-//CHECK: <key>file</key><integer>0</integer>
-//CHECK: </dict>
-//CHECK: <dict>
-//CHECK: <key>line</key><integer>142</integer>
-//CHECK: <key>col</key><integer>5</integer>
-//CHECK: <key>file</key><integer>0</integer>
-//CHECK: </dict>
-//CHECK: </array>
-//CHECK: <key>end</key>
-//CHECK: <array>
-//CHECK: <dict>
-//CHECK: <key>line</key><integer>142</integer>
//CHECK: <key>col</key><integer>12</integer>
//CHECK: <key>file</key><integer>0</integer>
//CHECK: </dict>
Modified: cfe/branches/tooling/test/Analysis/malloc-sizeof.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc-sizeof.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc-sizeof.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc-sizeof.c Tue May 8 03:47:31 2012
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.MallocSizeof -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.MallocSizeof -verify %s
#include <stddef.h>
void *malloc(size_t size);
void *calloc(size_t nmemb, size_t size);
void *realloc(void *ptr, size_t size);
+void free(void *ptr);
struct A {};
struct B {};
@@ -13,15 +14,22 @@
int *ip1 = malloc(sizeof(1));
int *ip2 = malloc(4 * sizeof(int));
- long *lp1 = malloc(sizeof(short)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'short'}}
- long *lp2 = malloc(5 * sizeof(double)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'double'}}
- long *lp3 = malloc(5 * sizeof(char) + 2); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'char'}}
+ long *lp1 = malloc(sizeof(short)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'short'}}
+ long *lp2 = malloc(5 * sizeof(double)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'double'}}
+ long *lp3 = malloc(5 * sizeof(char) + 2); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'char'}}
struct A *ap1 = calloc(1, sizeof(struct A));
struct A *ap2 = calloc(2, sizeof(*ap1));
- struct A *ap3 = calloc(2, sizeof(ap1)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}}
- struct A *ap4 = calloc(3, sizeof(struct A*)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}}
- struct A *ap5 = calloc(4, sizeof(struct B)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}}
+ struct A *ap3 = calloc(2, sizeof(ap1)); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct A *'}}
+ struct A *ap4 = calloc(3, sizeof(struct A*)); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct A *'}}
+ struct A *ap5 = calloc(4, sizeof(struct B)); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct B'}}
struct A *ap6 = realloc(ap5, sizeof(struct A));
- struct A *ap7 = realloc(ap5, sizeof(struct B)); // expected-warning {{Result of 'realloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}}
+ struct A *ap7 = realloc(ap5, sizeof(struct B)); // expected-warning {{Result of 'realloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct B'}}
+}
+
+// Don't warn when the types differ only by constness.
+void ignore_const() {
+ const char **x = (const char **)malloc(1 * sizeof(char *)); // no-warning
+ const char ***y = (const char ***)malloc(1 * sizeof(char *)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'const char **', which is incompatible with sizeof operand type 'char *'}}
+ free(x);
}
Modified: cfe/branches/tooling/test/Analysis/malloc.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.c (original)
+++ cfe/branches/tooling/test/Analysis/malloc.c Tue May 8 03:47:31 2012
@@ -776,6 +776,65 @@
return p->n.m; // expected-warning {{leak}}
}
+// Pointer arithmetic, returning an ElementRegion.
+void *radar11329382(unsigned bl) {
+ void *ptr = malloc (16);
+ ptr = ptr + (2 - bl);
+ return ptr; // no warning
+}
+
+void __assert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__));
+int strcmp(const char *, const char *);
+char *a (void);
+void radar11270219(void) {
+ char *x = a(), *y = a();
+ (__builtin_expect(!(x && y), 0) ? __assert_rtn(__func__, "/Users/zaks/tmp/ex.c", 24, "x && y") : (void)0);
+ strcmp(x, y); // no warning
+}
+
+void radar_11358224_test_double_assign_ints_positive_2()
+{
+ void *ptr = malloc(16);
+ ptr = ptr; // expected-warning {{leak}}
+}
+
+// Assume that functions which take a function pointer can free memory even if
+// they are defined in system headers and take the const pointer to the
+// allocated memory. (radar://11160612)
+int const_ptr_and_callback(int, const char*, int n, void(*)(void*));
+void r11160612_1() {
+ char *x = malloc(12);
+ const_ptr_and_callback(0, x, 12, free); // no - warning
+}
+
+// Null is passed as callback.
+void r11160612_2() {
+ char *x = malloc(12);
+ const_ptr_and_callback(0, x, 12, 0); // expected-warning {{leak}}
+}
+
+// Callback is passed to a function defined in a system header.
+void r11160612_4() {
+ char *x = malloc(12);
+ sqlite3_bind_text_my(0, x, 12, free); // no - warning
+}
+
+// Passing callbacks in a struct.
+void r11160612_5(StWithCallback St) {
+ void *x = malloc(12);
+ dealocateMemWhenDoneByVal(x, St);
+}
+void r11160612_6(StWithCallback St) {
+ void *x = malloc(12);
+ dealocateMemWhenDoneByRef(&St, x);
+}
+
+int mySub(int, int);
+int myAdd(int, int);
+int fPtr(unsigned cond, int x) {
+ return (cond ? mySub : myAdd)(x, x);
+}
+
// ----------------------------------------------------------------------------
// Below are the known false positives.
@@ -823,3 +882,17 @@
ArrayL[0] = p;
}
+// Test double assignment through integers.
+static long glob;
+void test_double_assign_ints()
+{
+ void *ptr = malloc (16); // no-warning
+ glob = (long)(unsigned long)ptr;
+}
+
+void test_double_assign_ints_positive()
+{
+ void *ptr = malloc(16);
+ (void*)(long)(unsigned long)ptr; // expected-warning {{unused}} expected-warning {{leak}}
+}
+
Modified: cfe/branches/tooling/test/Analysis/malloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.cpp (original)
+++ cfe/branches/tooling/test/Analysis/malloc.cpp Tue May 8 03:47:31 2012
@@ -14,3 +14,24 @@
Foo aFunction() {
return malloc(10);
}
+
+// Assume that functions which take a function pointer can free memory even if
+// they are defined in system headers and take the const pointer to the
+// allocated memory. (radar://11160612)
+// Test default parameter.
+int const_ptr_and_callback_def_param(int, const char*, int n, void(*)(void*) = 0);
+void r11160612_3() {
+ char *x = (char*)malloc(12);
+ const_ptr_and_callback_def_param(0, x, 12);
+}
+
+// Test member function pointer.
+struct CanFreeMemory {
+ static void myFree(void*);
+};
+//This is handled because we look at the type of the parameter(not argument).
+void r11160612_3(CanFreeMemory* p) {
+ char *x = (char*)malloc(12);
+ const_ptr_and_callback_def_param(0, x, 12, p->myFree);
+}
+
Modified: cfe/branches/tooling/test/Analysis/malloc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.m (original)
+++ cfe/branches/tooling/test/Analysis/malloc.m Tue May 8 03:47:31 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class -fblocks %s
#include "system-header-simulator-objc.h"
@class NSString;
Modified: cfe/branches/tooling/test/Analysis/malloc.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/malloc.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/malloc.mm (original)
+++ cfe/branches/tooling/test/Analysis/malloc.mm Tue May 8 03:47:31 2012
@@ -153,4 +153,29 @@
void testCGDataProviderCreateWithData() {
void* b = calloc(8, 8);
CGDataProviderRef p = CGDataProviderCreateWithData(0, b, 8*8, releaseDataCallback);
+}
+
+// Assume that functions which take a function pointer can free memory even if
+// they are defined in system headers and take the const pointer to the
+// allocated memory. (radar://11160612)
+extern CGDataProviderRef UnknownFunWithCallback(void *info,
+ const void *data, size_t size,
+ CGDataProviderReleaseDataCallback releaseData)
+ __attribute__((visibility("default")));
+void testUnknownFunWithCallBack() {
+ void* b = calloc(8, 8);
+ CGDataProviderRef p = UnknownFunWithCallback(0, b, 8*8, releaseDataCallback);
+}
+
+// Test blocks.
+void acceptBlockParam(void *, void (^block)(void *), unsigned);
+void testCallWithBlockCallback() {
+ void *l = malloc(12);
+ acceptBlockParam(l, ^(void *i) { free(i); }, sizeof(char *));
+}
+
+// Test blocks in system headers.
+void testCallWithBlockCallbackInSystem() {
+ void *l = malloc(12);
+ SystemHeaderFunctionWithBlockParam(l, ^(void *i) { free(i); }, sizeof(char *));
}
\ No newline at end of file
Modified: cfe/branches/tooling/test/Analysis/misc-ps-region-store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/misc-ps-region-store.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/misc-ps-region-store.cpp (original)
+++ cfe/branches/tooling/test/Analysis/misc-ps-region-store.cpp Tue May 8 03:47:31 2012
@@ -578,3 +578,17 @@
if (y == 0)
return;
}
+
+// Test handling CXXScalarValueInitExprs.
+void rdar11401827() {
+ int x = int();
+ if (!x) {
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning {{null pointer}}
+ }
+ else {
+ int *p = 0;
+ *p = 0xDEADBEEF;
+ }
+}
+
Modified: cfe/branches/tooling/test/Analysis/misc-ps-region-store.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/misc-ps-region-store.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/misc-ps-region-store.m (original)
+++ cfe/branches/tooling/test/Analysis/misc-ps-region-store.m Tue May 8 03:47:31 2012
@@ -1341,3 +1341,23 @@
return values[index].value;
}
+// Test handling invalidating arrays passed to a block via captured
+// pointer value (not a __block variable).
+typedef void (^radar11125868_cb)(int *, unsigned);
+
+void rdar11125868_aux(radar11125868_cb cb);
+
+int rdar11125868() {
+ int integersStackArray[1];
+ int *integers = integersStackArray;
+ rdar11125868_aux(^(int *integerValue, unsigned index) {
+ integers[index] = integerValue[index];
+ });
+ return integers[0] == 0; // no-warning
+}
+
+int rdar11125868_positive() {
+ int integersStackArray[1];
+ int *integers = integersStackArray;
+ return integers[0] == 0; // expected-warning {{he left operand of '==' is a}}
+}
Modified: cfe/branches/tooling/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/misc-ps.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/misc-ps.m (original)
+++ cfe/branches/tooling/test/Analysis/misc-ps.m Tue May 8 03:47:31 2012
@@ -1,8 +1,8 @@
// NOTE: Use '-fobjc-gc' to test the analysis being run twice, and multiple reports are not issued.
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync,osx.AtomicCAS -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync,osx.AtomicCAS -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync,osx.AtomicCAS -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync,osx.AtomicCAS -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s
#ifndef __clang_analyzer__
#error __clang_analyzer__ not defined
@@ -494,6 +494,17 @@
}
@end
+// Do not crash when performing compare and swap on symbolic values.
+typedef int int32_t;
+typedef int int32;
+typedef int32 Atomic32;
+int OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue);
+void radar11390991_NoBarrier_CompareAndSwap(volatile Atomic32 *ptr,
+ Atomic32 old_value,
+ Atomic32 new_value) {
+ OSAtomicCompareAndSwap32(old_value, new_value, ptr);
+}
+
// PR 4594 - This was a crash when handling casts in SimpleSValuator.
void PR4594() {
char *buf[1];
Modified: cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m (original)
+++ cfe/branches/tooling/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m Tue May 8 03:47:31 2012
@@ -80,11 +80,11 @@
int marker(void) { // control reaches end of non-void function
}
+// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
-// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
+// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
-// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
// CHECK-darwin9-NOT: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
Modified: cfe/branches/tooling/test/Analysis/out-of-bounds.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/out-of-bounds.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/out-of-bounds.c (original)
+++ cfe/branches/tooling/test/Analysis/out-of-bounds.c Tue May 8 03:47:31 2012
@@ -128,11 +128,13 @@
buf[0][0] = 1; // no-warning
}
-// Testing if solver handles (symbol * constant) < constant
+// *** FIXME ***
+// We don't get a warning here yet because our symbolic constraint solving
+// doesn't handle: (symbol * constant) < constant
void test3(int x) {
int buf[100];
if (x < 0)
- buf[x] = 1; // expected-warning {{Out of bound memory access (accessed memory precedes memory block)}}
+ buf[x] = 1;
}
// *** FIXME ***
Modified: cfe/branches/tooling/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/retain-release.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/retain-release.m (original)
+++ cfe/branches/tooling/test/Analysis/retain-release.m Tue May 8 03:47:31 2012
@@ -1305,6 +1305,11 @@
TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}}
}
+void testattr2_b_11358224_self_assign_looses_the_leak() {
+ TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit];// expected-warning{{leak}}
+ x = x;
+}
+
void testattr2_c() {
TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning
[x release];
@@ -1681,6 +1686,32 @@
}
}
+// Stop tracking objects passed to functions, which take callbacks as parameters.
+// radar://10973977
+typedef int (*CloseCallback) (void *);
+void ReaderForIO(CloseCallback ioclose, void *ioctx);
+int IOClose(void *context);
+
+ at protocol SInS <NSObject>
+ at end
+
+ at interface radar10973977 : NSObject
+- (id<SInS>)inputS;
+- (void)reader;
+ at end
+
+ at implementation radar10973977
+- (void)reader
+{
+ id<SInS> inputS = [[self inputS] retain];
+ ReaderForIO(IOClose, inputS);
+}
+- (id<SInS>)inputS
+{
+ return 0;
+}
+ at end
+
//===----------------------------------------------------------------------===//
// Test returning allocated memory in a struct.
//
@@ -1753,3 +1784,17 @@
}
}
+// Test NSLog doesn't escape tracked objects.
+void rdar11400885(int y)
+{
+ @autoreleasepool {
+ NSString *printString;
+ if(y > 2)
+ printString = [[NSString alloc] init];
+ else
+ printString = [[NSString alloc] init];
+ NSLog(@"Once %@", printString);
+ [printString release];
+ NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}}
+ }
+}
Modified: cfe/branches/tooling/test/Analysis/stack-addr-ps.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/stack-addr-ps.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/stack-addr-ps.cpp (original)
+++ cfe/branches/tooling/test/Analysis/stack-addr-ps.cpp Tue May 8 03:47:31 2012
@@ -84,3 +84,9 @@
return x;
}
};
+
+// rdar://11345441
+int* f5() {
+ int& i = i; // expected-warning {{Assigned value is garbage or undefined}} expected-note {{binding reference variable 'i' here}}
+ return &i; // expected-warning {{address of stack memory associated with local variable 'i' returned}}
+}
Modified: cfe/branches/tooling/test/Analysis/string.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/string.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/string.c (original)
+++ cfe/branches/tooling/test/Analysis/string.c Tue May 8 03:47:31 2012
@@ -1122,3 +1122,35 @@
if (strncasecmp("ab\0zz", "ab\0yy", 4) != 0)
(void)*(char*)0; // no-warning
}
+
+//===----------------------------------------------------------------------===
+// Miscellaneous extras.
+//===----------------------------------------------------------------------===
+
+// See additive-folding.cpp for a description of this bug.
+// This test is insurance in case we significantly change how SymExprs are
+// evaluated. It isn't as good as additive-folding.cpp's version
+// because it will only actually be a test on systems where
+// sizeof(1 == 1) < sizeof(size_t).
+// We could add a triple if it becomes necessary.
+void PR12206(const char *x) {
+ // This test is only useful under these conditions.
+ size_t comparisonSize = sizeof(1 == 1);
+ if (sizeof(size_t) <= comparisonSize) return;
+
+ // Create a value that requires more bits to store than a comparison result.
+ size_t value = 1UL;
+ value <<= 8 * comparisonSize;
+ value += 1;
+
+ // Constrain the length of x.
+ if (strlen(x) != value) return;
+
+ // Test relational operators.
+ if (strlen(x) < 2) { (void)*(char*)0; } // no-warning
+ if (2 > strlen(x)) { (void)*(char*)0; } // no-warning
+
+ // Test equality operators.
+ if (strlen(x) == 1) { (void)*(char*)0; } // no-warning
+ if (1 == strlen(x)) { (void)*(char*)0; } // no-warning
+}
Modified: cfe/branches/tooling/test/Analysis/system-header-simulator-objc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/system-header-simulator-objc.h?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/system-header-simulator-objc.h (original)
+++ cfe/branches/tooling/test/Analysis/system-header-simulator-objc.h Tue May 8 03:47:31 2012
@@ -112,3 +112,5 @@
extern CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy(CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator);
extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator);
extern void CFStringAppend(CFMutableStringRef theString, CFStringRef appendedString);
+
+void SystemHeaderFunctionWithBlockParam(void *, void (^block)(void *), unsigned);
Modified: cfe/branches/tooling/test/Analysis/system-header-simulator.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/system-header-simulator.h?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/system-header-simulator.h (original)
+++ cfe/branches/tooling/test/Analysis/system-header-simulator.h Tue May 8 03:47:31 2012
@@ -36,3 +36,13 @@
fpos_t (*)(void *, fpos_t, int),
int (*)(void *));
+int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*));
+
+typedef void (*freeCallback) (void*);
+typedef struct {
+ int i;
+ freeCallback fc;
+} StWithCallback;
+
+int dealocateMemWhenDoneByVal(void*, StWithCallback);
+int dealocateMemWhenDoneByRef(StWithCallback*, const void*);
Modified: cfe/branches/tooling/test/Analysis/taint-generic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Analysis/taint-generic.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Analysis/taint-generic.c (original)
+++ cfe/branches/tooling/test/Analysis/taint-generic.c Tue May 8 03:47:31 2012
@@ -183,3 +183,32 @@
scanf("%d", &x);
int vla[x]; // expected-warning{{Declared variable-length array (VLA) has tainted size}}
}
+
+// This computation used to take a very long time.
+#define longcmp(a,b,c) { \
+ a -= c; a ^= c; c += b; b -= a; b ^= (a<<6) | (a >> (32-b)); a += c; c -= b; c ^= b; b += a; \
+ a -= c; a ^= c; c += b; b -= a; b ^= a; a += c; c -= b; c ^= b; b += a; }
+
+unsigned radar11369570_hanging(const unsigned char *arr, int l) {
+ unsigned a, b, c;
+ a = b = c = 0x9899e3 + l;
+ while (l >= 6) {
+ unsigned t;
+ scanf("%d", &t);
+ a += b;
+ a ^= a;
+ a += (arr[3] + ((unsigned) arr[2] << 8) + ((unsigned) arr[1] << 16) + ((unsigned) arr[0] << 24));
+ longcmp(a, t, c);
+ l -= 12;
+ }
+ return 5/a; // expected-warning {{Division by a tainted value, possibly zero}}
+}
+
+// Check that we do not assert of the following code.
+int SymSymExprWithDiffTypes(void* p) {
+ int i;
+ scanf("%d", &i);
+ int j = (i % (int)(long)p);
+ return 5/j; // expected-warning {{Division by a tainted value, possibly zero}}
+}
+
Modified: cfe/branches/tooling/test/CXX/class/class.mem/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/class/class.mem/p2.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/class/class.mem/p2.cpp (original)
+++ cfe/branches/tooling/test/CXX/class/class.mem/p2.cpp Tue May 8 03:47:31 2012
@@ -56,20 +56,3 @@
template struct A2<int>;
}
-
-namespace PR12629 {
- struct S {
- static int (f)() throw();
- static int ((((((g))))() throw(U)));
- int (*h)() noexcept(false);
- static int (&i)() noexcept(true);
- static int (*j)() throw(U); // expected-error {{type name}} \
- // expected-error {{expected ')'}} expected-note {{to match}}
-
- struct U {};
- };
- static_assert(noexcept(S::f()), "");
- static_assert(!noexcept(S::g()), "");
- static_assert(!noexcept(S().h()), "");
- static_assert(noexcept(S::i()), "");
-}
Modified: cfe/branches/tooling/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp Tue May 8 03:47:31 2012
@@ -10,7 +10,10 @@
void test_classification(char *ptr) {
int (&fr0)(int) = reinterpret_cast<int (&&)(int)>(f);
int &&ir0 = reinterpret_cast<int &&>(*ptr);
- int &&ir1 = reinterpret_cast<int &&>(0);
- int &&ir2 = reinterpret_cast<int &&>('a');
+ int &&ir1 = reinterpret_cast<int &&>(0); // expected-error {{rvalue to reference type}}
+ int &&ir2 = reinterpret_cast<int &&>('a'); // expected-error {{rvalue to reference type}}
int &&ir3 = reinterpret_cast<int &&>(xvalue<char>());
+ // Per DR1268, reinterpret_cast can convert between lvalues and xvalues.
+ int &ir4 = reinterpret_cast<int &>(xvalue<char>());
+ int &&ir5 = reinterpret_cast<int &&>(*ptr);
}
Modified: cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp Tue May 8 03:47:31 2012
@@ -91,10 +91,11 @@
namespace PR12564 {
struct Base {
- void bar(Base&) {}
+ void bar(Base&) {} // unexpected-note {{here}}
};
struct Derived : Base {
- void foo(Derived& d) noexcept(noexcept(d.bar(d))) {}
+ // FIXME: This should be accepted.
+ void foo(Derived& d) noexcept(noexcept(d.bar(d))) {} // unexpected-error {{cannot bind to a value of unrelated type}}
};
}
Modified: cfe/branches/tooling/test/CXX/special/class.copy/p11.0x.copy.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.copy/p11.0x.copy.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.copy/p11.0x.copy.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.copy/p11.0x.copy.cpp Tue May 8 03:47:31 2012
@@ -8,7 +8,7 @@
// -- a variant member with a non-trivial corresponding constructor
union DeletedNTVariant {
- NonTrivial NT; // expected-note{{copy constructor of union 'DeletedNTVariant' is implicitly deleted because field 'NT' has a non-trivial copy constructor}}
+ NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}}
DeletedNTVariant();
};
DeletedNTVariant DVa;
@@ -16,7 +16,7 @@
struct DeletedNTVariant2 {
union {
- NonTrivial NT; // expected-note{{copy constructor of union 'DeletedNTVariant2' is implicitly deleted because field 'NT' has a non-trivial copy constructor}}
+ NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant2' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}}
};
DeletedNTVariant2();
};
Modified: cfe/branches/tooling/test/CXX/special/class.ctor/p5-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.ctor/p5-0x.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.ctor/p5-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.ctor/p5-0x.cpp Tue May 8 03:47:31 2012
@@ -21,7 +21,7 @@
// - X is a union-like class that has a variant member with a non-trivial
// default constructor,
-union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{default constructor of union 'Deleted1a' is implicitly deleted because field 'u' has a non-trivial default constructor}}
+union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{default constructor of 'Deleted1a' is implicitly deleted because variant field 'u' has a non-trivial default constructor}}
Deleted1a d1a; // expected-error {{implicitly-deleted default constructor}}
union NotDeleted1a { DefaultedDefCtor1 nu; };
NotDeleted1a nd1a;
@@ -53,7 +53,7 @@
expected-warning {{does not declare any constructor}} \
expected-note {{will never be initialized}}
Deleted3a d3a; // expected-error {{implicitly-deleted default constructor}}
-class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor1' would not be initialized}}
+class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor1 [42]' would not be initialized}}
Deleted3b d3b; // expected-error {{implicitly-deleted default constructor}}
class Deleted3c { const DefaultedDefCtor2 a; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor2' would not be initialized}}
Deleted3c d3c; // expected-error {{implicitly-deleted default constructor}}
@@ -77,7 +77,7 @@
union Deleted4a {
const int a;
const int b;
- const UserProvidedDefCtor c; // expected-note {{because field 'c' has a non-trivial default constructor}}
+ const UserProvidedDefCtor c; // expected-note {{because variant field 'c' has a non-trivial default constructor}}
};
Deleted4a d4a; // expected-error {{implicitly-deleted default constructor}}
union NotDeleted4a { const int a; int b; };
Modified: cfe/branches/tooling/test/CXX/special/class.ctor/p6-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.ctor/p6-0x.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.ctor/p6-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.ctor/p6-0x.cpp Tue May 8 03:47:31 2012
@@ -55,3 +55,42 @@
struct B {
friend A::A(); // expected-error {{non-constexpr declaration of 'A' follows constexpr declaration}}
};
+
+namespace UnionCtors {
+ union A { // expected-note {{here}}
+ int a;
+ int b;
+ };
+ union B {
+ int a;
+ int b = 5;
+ };
+ union C {
+ int a = 5;
+ int b;
+ };
+ struct D {
+ union {
+ int a = 5;
+ int b;
+ };
+ union {
+ int c;
+ int d = 5;
+ };
+ };
+ struct E { // expected-note {{here}}
+ union {
+ int a;
+ int b;
+ };
+ };
+
+ struct Test {
+ friend constexpr A::A() noexcept; // expected-error {{follows non-constexpr declaration}}
+ friend constexpr B::B() noexcept;
+ friend constexpr C::C() noexcept;
+ friend constexpr D::D() noexcept;
+ friend constexpr E::E() noexcept; // expected-error {{follows non-constexpr declaration}}
+ };
+}
Modified: cfe/branches/tooling/test/CXX/special/class.dtor/p5-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.dtor/p5-0x.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.dtor/p5-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.dtor/p5-0x.cpp Tue May 8 03:47:31 2012
@@ -16,25 +16,25 @@
// destructor.
union A1 {
A1();
- NonTrivDtor n; // expected-note {{destructor of union 'A1' is implicitly deleted because field 'n' has a non-trivial destructor}}
+ NonTrivDtor n; // expected-note {{destructor of 'A1' is implicitly deleted because variant field 'n' has a non-trivial destructor}}
};
A1 a1; // expected-error {{deleted function}}
struct A2 {
A2();
union {
- NonTrivDtor n; // expected-note {{because field 'n' has a non-trivial destructor}}
+ NonTrivDtor n; // expected-note {{because variant field 'n' has a non-trivial destructor}}
};
};
A2 a2; // expected-error {{deleted function}}
union A3 {
A3();
- NonTrivDtor n[3]; // expected-note {{because field 'n' has a non-trivial destructor}}
+ NonTrivDtor n[3]; // expected-note {{because variant field 'n' has a non-trivial destructor}}
};
A3 a3; // expected-error {{deleted function}}
struct A4 {
A4();
union {
- NonTrivDtor n[3]; // expected-note {{because field 'n' has a non-trivial destructor}}
+ NonTrivDtor n[3]; // expected-note {{because variant field 'n' has a non-trivial destructor}}
};
};
A4 a4; // expected-error {{deleted function}}
Modified: cfe/branches/tooling/test/CXX/special/class.inhctor/elsewhere.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.inhctor/elsewhere.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.inhctor/elsewhere.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.inhctor/elsewhere.cpp Tue May 8 03:47:31 2012
@@ -9,15 +9,15 @@
B1(int);
};
-using B1::B1; // expected-error {{using declaration can not refer to class member}}
+using B1::B1; // expected-error {{using declaration can not refer to class member}} expected-error {{not supported}}
// C++0x [namespace.udecl]p10:
// A using-declaration is a declaration and can therefore be used repeatedly
// where (and only where) multiple declarations are allowed.
struct I1 : B1 {
- using B1::B1; // expected-note {{previous using declaration}}
- using B1::B1; // expected-error {{redeclaration of using decl}}
+ using B1::B1; // expected-note {{previous using declaration}} expected-error {{not supported}}
+ using B1::B1; // expected-error {{redeclaration of using decl}} expected-error {{not supported}}
};
// C++0x [namespace.udecl]p3:
@@ -27,31 +27,31 @@
// shall name a direct base class of the class being defined.
struct D1 : I1 {
- using B1::B1; // expected-error {{'B1' is not a direct base of 'D1', can not inherit constructors}}
+ using B1::B1; // expected-error {{'B1' is not a direct base of 'D1', can not inherit constructors}} expected-error {{not supported}}
};
template<typename T> struct A {};
template<typename T> struct B : A<bool>, A<char> {
- using A<T>::A; // expected-error {{'A<double>::', which is not a base class of 'B<double>'}}
+ using A<T>::A; // expected-error {{'A<double>::', which is not a base class of 'B<double>'}} expected-error {{not supported}}
};
B<bool> bb;
B<char> bc;
B<double> bd; // expected-note {{here}}
template<typename T> struct C : A<T> {
- using A<bool>::A; // expected-error {{'A<bool>::', which is not a base class of 'C<char>'}}
+ using A<bool>::A; // expected-error {{'A<bool>::', which is not a base class of 'C<char>'}} expected-error {{not supported}}
};
C<bool> cb;
C<char> cc; // expected-note {{here}}
template<typename T> struct D : A<T> {};
template<typename T> struct E : D<T> {
- using A<bool>::A; // expected-error {{'A<bool>' is not a direct base of 'E<bool>', can not inherit}}
+ using A<bool>::A; // expected-error {{'A<bool>' is not a direct base of 'E<bool>', can not inherit}} expected-error {{not supported}}
};
E<bool> eb; // expected-note {{here}}
template<typename T> struct F : D<bool> {
- using A<T>::A; // expected-error {{'A<bool>' is not a direct base of 'F<bool>'}}
+ using A<T>::A; // expected-error {{'A<bool>' is not a direct base of 'F<bool>'}} expected-error {{not supported}}
};
F<bool> fb; // expected-note {{here}}
Modified: cfe/branches/tooling/test/CXX/special/class.inhctor/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.inhctor/p3.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.inhctor/p3.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.inhctor/p3.cpp Tue May 8 03:47:31 2012
@@ -5,7 +5,7 @@
B1(int, int);
};
struct D1 : B1 {
- using B1::B1;
+ using B1::B1; // expected-error {{not supported}}
};
D1 d1a(1), d1b(1, 1);
@@ -15,7 +15,7 @@
explicit B2(int, int = 0, int = 0);
};
struct D2 : B2 { // expected-note 2 {{candidate constructor}}
- using B2::B2;
+ using B2::B2; // expected-error {{not supported}}
};
D2 d2a(1), d2b(1, 1), d2c(1, 1, 1);
@@ -25,18 +25,18 @@
B3(void*); // expected-note {{inherited from here}}
};
struct D3 : B3 { // expected-note 2 {{candidate constructor}}
- using B3::B3; // expected-note {{candidate constructor (inherited)}}
+ using B3::B3; // expected-note {{candidate constructor (inherited)}} expected-error {{not supported}}
};
D3 fd3() { return 1; } // expected-error {{no viable conversion}}
template<typename T> struct T1 : B1 {
- using B1::B1;
+ using B1::B1; // expected-error {{not supported}}
};
template<typename T> struct T2 : T1<T> {
- using T1<int>::T1;
+ using T1<int>::T1; // expected-error {{not supported}}
};
template<typename T> struct T3 : T1<int> {
- using T1<T>::T1;
+ using T1<T>::T1; // expected-error {{not supported}}
};
struct U {
friend T1<int>::T1(int);
Modified: cfe/branches/tooling/test/CXX/special/class.inhctor/p7.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/special/class.inhctor/p7.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/special/class.inhctor/p7.cpp (original)
+++ cfe/branches/tooling/test/CXX/special/class.inhctor/p7.cpp Tue May 8 03:47:31 2012
@@ -8,12 +8,12 @@
B2(int); // expected-note {{conflicting constructor}}
};
struct D1 : B1, B2 {
- using B1::B1; // expected-note {{inherited here}}
- using B2::B2; // expected-error {{already inherited constructor with the same signature}}
+ using B1::B1; // expected-note {{inherited here}} expected-error {{not supported}}
+ using B2::B2; // expected-error {{already inherited constructor with the same signature}} expected-error {{not supported}}
};
struct D2 : B1, B2 {
- using B1::B1;
- using B2::B2;
+ using B1::B1; // expected-error {{not supported}}
+ using B2::B2; // expected-error {{not supported}}
D2(int);
};
@@ -22,8 +22,8 @@
};
template<typename T> struct B4 : B3<T>, B1 {
B4();
- using B3<T>::B3; // expected-note {{inherited here}}
- using B1::B1; // expected-error {{already inherited}}
+ using B3<T>::B3; // expected-note {{inherited here}} expected-error {{not supported}}
+ using B1::B1; // expected-error {{already inherited}} expected-error {{not supported}}
};
B4<char> b4c;
B4<int> b4i; // expected-note {{here}}
Modified: cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp (original)
+++ cfe/branches/tooling/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp Tue May 8 03:47:31 2012
@@ -13,9 +13,9 @@
eval<A<int>> eA;
eval<B<int, float>> eB;
-eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17> >'}}
-eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17> >'}}
-eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17> >}}
+eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17>>'}}
+eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17>>'}}
+eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17>>}}
template<template <int ...N> class TT> struct X0 { }; // expected-note{{previous non-type template parameter with type 'int' is here}}
template<int I, int J, int ...Rest> struct X0a;
Modified: cfe/branches/tooling/test/CXX/temp/temp.spec/temp.explicit/p12.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CXX/temp/temp.spec/temp.explicit/p12.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CXX/temp/temp.spec/temp.explicit/p12.cpp (original)
+++ cfe/branches/tooling/test/CXX/temp/temp.spec/temp.explicit/p12.cpp Tue May 8 03:47:31 2012
@@ -1,6 +1,49 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-char* p = 0;
-template<class T> T g(T x = &p) { return x; }
-template int g<int>(int); // OK even though &p isn't an int.
+namespace test0 {
+ char* p = 0;
+ template<class T> T g(T x = &p) { return x; }
+ template int g<int>(int); // OK even though &p isn't an int.
+}
+// Don't impose access restrictions on explicit instantiations.
+namespace test1 {
+ class A {
+ class Private {};
+ public:
+ typedef Private Public;
+ };
+
+ template <class T> class Temp {
+ static Temp<A::Public> make() { return Temp<A::Public>(); }
+ };
+ template class Temp<A::Private>;
+
+ // FIXME: this ought to be an error, but it isn't because Sema is
+ // silently failing to create a declaration for the explicit
+ // instantiation.
+ template class Temp<A::Private> Temp<int>::make();
+}
+
+// Don't impose access restrictions on explicit specializations,
+// either. This goes here because it's an extension of the rule for
+// explicit instantiations and doesn't have any independent support.
+namespace test2 {
+ class A {
+ class Private {}; // expected-note {{implicitly declared private here}}
+ public:
+ typedef Private Public;
+ };
+
+ template <class T> class Temp {
+ static Temp<A::Public> make();
+ };
+ template <> class Temp<A::Private> {
+ public:
+ Temp(int x) {}
+ };
+
+ template <> class Temp<A::Private> Temp<int>::make() { // expected-error {{'Private' is a private member of 'test2::A'}}
+ return Temp<A::Public>(0);
+ }
+}
Modified: cfe/branches/tooling/test/CodeGen/annotations-builtin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/annotations-builtin.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/annotations-builtin.c (original)
+++ cfe/branches/tooling/test/CodeGen/annotations-builtin.c Tue May 8 03:47:31 2012
@@ -25,9 +25,7 @@
// CHECK: call i32 @llvm.annotation.i32
long long lla = __builtin_annotation(llfoo, "annotation_a");
-// CHECK: trunc i64 {{.*}} to i32
-// CHECK-NEXT: call i32 @llvm.annotation.i32
-// CHECK-NEXT: zext i32 {{.*}} to i64
+// CHECK: call i64 @llvm.annotation.i64
int inta = __builtin_annotation(intfoo, "annotation_a");
// CHECK: load i32* @intfoo
@@ -35,15 +33,11 @@
// CHECK-NEXT: store
short shorta = __builtin_annotation(shortfoo, "annotation_a");
-// CHECK: sext i16 {{.*}} to i32
-// CHECK-NEXT: call i32 @llvm.annotation.i32
-// CHECK-NEXT: trunc i32 {{.*}} to i16
+// CHECK: call i16 @llvm.annotation.i16
char chara = __builtin_annotation(charfoo, "annotation_a");
-// CHECK: sext i8 {{.*}} to i32
-// CHECK-NEXT: call i32 @llvm.annotation.i32
-// CHECK-NEXT: trunc i32 {{.*}} to i8
-//
+// CHECK: call i8 @llvm.annotation.i8
+
char **arg = (char**) __builtin_annotation((int) argv, "annotation_a");
// CHECK: ptrtoint i8** {{.*}} to
// CHECK: call i32 @llvm.annotation.i32
Modified: cfe/branches/tooling/test/CodeGen/blocks.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/blocks.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/blocks.c (original)
+++ cfe/branches/tooling/test/CodeGen/blocks.c Tue May 8 03:47:31 2012
@@ -40,3 +40,29 @@
_Bool b = 0;
f3_helper(^{ if (b) {} });
}
+
+// rdar://problem/11322251
+// The bool can fill in between the header and the long long.
+// Add the appropriate amount of padding between them.
+void f4_helper(long long (^)(void));
+// CHECK: define void @f4()
+void f4(void) {
+ _Bool b = 0;
+ long long ll = 0;
+ // CHECK: alloca <{ i8*, i32, i32, i8*, {{%.*}}*, i8, [3 x i8], i64 }>, align 8
+ f4_helper(^{ if (b) return ll; return 0LL; });
+}
+
+// rdar://problem/11354538
+// The alignment after rounding up to the align of F5 is actually
+// greater than the required alignment. Don't assert.
+struct F5 {
+ char buffer[32] __attribute((aligned));
+};
+void f5_helper(void (^)(struct F5 *));
+// CHECK: define void @f5()
+void f5(void) {
+ struct F5 value;
+ // CHECK: alloca <{ i8*, i32, i32, i8*, {{%.*}}*, [12 x i8], [[F5:%.*]] }>, align 16
+ f5_helper(^(struct F5 *slot) { *slot = value; });
+}
Modified: cfe/branches/tooling/test/CodeGen/builtins-x86.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/builtins-x86.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/builtins-x86.c (original)
+++ cfe/branches/tooling/test/CodeGen/builtins-x86.c Tue May 8 03:47:31 2012
@@ -344,7 +344,6 @@
tmp_V16c = __builtin_ia32_lddqu(tmp_cCp);
tmp_V2LLi = __builtin_ia32_palignr128(tmp_V2LLi, tmp_V2LLi, imm_i);
tmp_V1LLi = __builtin_ia32_palignr(tmp_V1LLi, tmp_V1LLi, imm_i);
- (void) __builtin_ia32_storelv4si(tmp_V2ip, tmp_V2LLi);
#ifdef USE_SSE4
tmp_V16c = __builtin_ia32_pblendvb128(tmp_V16c, tmp_V16c, tmp_V16c);
tmp_V8s = __builtin_ia32_pblendw128(tmp_V8s, tmp_V8s, imm_i_0_256);
Modified: cfe/branches/tooling/test/CodeGen/catch-undef-behavior.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/catch-undef-behavior.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/catch-undef-behavior.c (original)
+++ cfe/branches/tooling/test/CodeGen/catch-undef-behavior.c Tue May 8 03:47:31 2012
@@ -1,7 +1,17 @@
-// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm-only %s
+// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm %s -o - | FileCheck %s
// PR6805
+// CHECK: @foo
void foo() {
union { int i; } u;
+ // CHECK: objectsize
+ // CHECK: icmp uge
u.i=1;
}
+
+// CHECK: @bar
+int bar(int *a) {
+ // CHECK: objectsize
+ // CHECK: icmp uge
+ return *a;
+}
Modified: cfe/branches/tooling/test/CodeGen/sse-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGen/sse-builtins.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGen/sse-builtins.c (original)
+++ cfe/branches/tooling/test/CodeGen/sse-builtins.c Tue May 8 03:47:31 2012
@@ -151,3 +151,9 @@
// CHECK: @llvm.x86.sse41.round.sd
return _mm_round_sd(x, y, 2);
}
+
+void test_storel_epi64(__m128i x, void* y) {
+ // CHECK: define void @test_storel_epi64
+ // CHECK: store {{.*}} i64* {{.*}}, align 1{{$}}
+ _mm_storel_epi64(y, x);
+}
Modified: cfe/branches/tooling/test/CodeGenCXX/class-layout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/class-layout.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/class-layout.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/class-layout.cpp Tue May 8 03:47:31 2012
@@ -77,3 +77,17 @@
class E : public B {};
E *e;
}
+
+// <rdar://problem/11324125>: Make sure this doesn't crash. (It's okay
+// if we start rejecting it at some point.)
+namespace Test7 {
+ #pragma pack (1)
+ class A {};
+ // CHECK: %"class.Test7::B" = type <{ i32 (...)**, %"class.Test7::A" }>
+ class B {
+ virtual ~B();
+ A a;
+ };
+ B* b;
+ #pragma pack ()
+}
Modified: cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/const-init-cxx11.cpp Tue May 8 03:47:31 2012
@@ -49,6 +49,17 @@
// CHECK: @_ZN11StructUnion1fE = global {{.*}} { i32 5 }
D f;
+
+ union E {
+ int a;
+ void *b = &f;
+ };
+
+ // CHECK: @_ZN11StructUnion1gE = global {{.*}} @_ZN11StructUnion1fE
+ E g;
+
+ // CHECK: @_ZN11StructUnion1hE = global {{.*}} @_ZN11StructUnion1fE
+ E h = E();
}
namespace BaseClass {
Modified: cfe/branches/tooling/test/CodeGenCXX/destructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/destructors.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/destructors.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/destructors.cpp Tue May 8 03:47:31 2012
@@ -350,6 +350,22 @@
// CHECK: unreachable
}
+// PR12710
+namespace test9 {
+ struct ArgType {
+ ~ArgType();
+ };
+ template<typename T>
+ void f1(const ArgType& = ArgType());
+ void f2();
+ void bar() {
+ f1<int>();
+ f2();
+ }
+ // CHECK: call void @_ZN5test97ArgTypeD1Ev(%"struct.test9::ArgType"* %
+ // CHECK: call void @_ZN5test92f2Ev()
+}
+
// Checks from test3:
// CHECK: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::<anonymous namespace>::D"* %this) unnamed_addr
Modified: cfe/branches/tooling/test/CodeGenCXX/inheriting-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/inheriting-constructor.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/inheriting-constructor.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/inheriting-constructor.cpp Tue May 8 03:47:31 2012
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// XFAIL: *
+
// PR12219
struct A { A(int); virtual ~A(); };
struct B : A { using A::A; ~B(); };
Modified: cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/mangle-ms.cpp Tue May 8 03:47:31 2012
@@ -103,3 +103,16 @@
void zeta(int (^)(int, int)) {}
// CHECK: @"\01?zeta@@YAXP_EAHHH at Z@Z"
+void operator_new_delete() {
+ char *ptr = new char;
+// CHECK: @"\01??2 at YAPAXI@Z"
+
+ delete ptr;
+// CHECK: @"\01??3 at YAXPAX@Z"
+
+ char *array = new char[42];
+// CHECK: @"\01??_U at YAPAXI@Z"
+
+ delete [] array;
+// CHECK: @"\01??_V at YAXPAX@Z"
+}
Modified: cfe/branches/tooling/test/CodeGenCXX/member-function-pointers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/member-function-pointers.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/member-function-pointers.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/member-function-pointers.cpp Tue May 8 03:47:31 2012
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin9 | FileCheck %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-apple-darwin9 | FileCheck -check-prefix LP32 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix ARM %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix CODE-LP64 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-unknown-unknown | FileCheck -check-prefix CODE-LP32 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix GLOBAL-LP64 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-unknown-unknown | FileCheck -check-prefix GLOBAL-LP32 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix GLOBAL-ARM %s
struct A { int a; void f(); virtual void vf1(); virtual void vf2(); };
struct B { int b; virtual void g(); };
@@ -11,66 +13,56 @@
void (B::*pb)();
void (C::*pc)();
-// CHECK: @pa2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }, align 8
+// GLOBAL-LP64: @pa2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }, align 8
void (A::*pa2)() = &A::f;
-// CHECK: @pa3 = global { i64, i64 } { i64 1, i64 0 }, align 8
-// CHECK-LP32: @pa3 = global { i32, i32 } { i32 1, i32 0 }, align 4
+// GLOBAL-LP64: @pa3 = global { i64, i64 } { i64 1, i64 0 }, align 8
+// GLOBAL-LP32: @pa3 = global { i32, i32 } { i32 1, i32 0 }, align 4
void (A::*pa3)() = &A::vf1;
-// CHECK: @pa4 = global { i64, i64 } { i64 9, i64 0 }, align 8
-// CHECK-LP32: @pa4 = global { i32, i32 } { i32 5, i32 0 }, align 4
+// GLOBAL-LP64: @pa4 = global { i64, i64 } { i64 9, i64 0 }, align 8
+// GLOBAL-LP32: @pa4 = global { i32, i32 } { i32 5, i32 0 }, align 4
void (A::*pa4)() = &A::vf2;
-// CHECK: @pc2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 16 }, align 8
+// GLOBAL-LP64: @pc2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 16 }, align 8
void (C::*pc2)() = &C::f;
-// CHECK: @pc3 = global { i64, i64 } { i64 1, i64 0 }, align 8
+// GLOBAL-LP64: @pc3 = global { i64, i64 } { i64 1, i64 0 }, align 8
void (A::*pc3)() = &A::vf1;
-// Tests for test10.
-// CHECK: @_ZN6test101aE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 0 }, align 8
-// CHECK: @_ZN6test101bE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8
-// CHECK: @_ZN6test101cE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8
-// CHECK: @_ZN6test101dE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 16 }, align 8
-// CHECK-LP32: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4
-// CHECK-LP32: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4
-// CHECK-LP32: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4
-// CHECK-LP32: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
-
void f() {
- // CHECK: store { i64, i64 } zeroinitializer, { i64, i64 }* @pa
+ // CODE-LP64: store { i64, i64 } zeroinitializer, { i64, i64 }* @pa
pa = 0;
// Is this okay? What are LLVM's volatile semantics for structs?
- // CHECK: store volatile { i64, i64 } zeroinitializer, { i64, i64 }* @vpa
+ // CODE-LP64: store volatile { i64, i64 } zeroinitializer, { i64, i64 }* @vpa
vpa = 0;
- // CHECK: [[TMP:%.*]] = load { i64, i64 }* @pa, align 8
- // CHECK: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1
- // CHECK: [[ADJ:%.*]] = add nsw i64 [[TMPADJ]], 16
- // CHECK: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1
- // CHECK: store { i64, i64 } [[RES]], { i64, i64 }* @pc, align 8
+ // CODE-LP64: [[TMP:%.*]] = load { i64, i64 }* @pa, align 8
+ // CODE-LP64: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1
+ // CODE-LP64: [[ADJ:%.*]] = add nsw i64 [[TMPADJ]], 16
+ // CODE-LP64: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1
+ // CODE-LP64: store { i64, i64 } [[RES]], { i64, i64 }* @pc, align 8
pc = pa;
- // CHECK: [[TMP:%.*]] = load { i64, i64 }* @pc, align 8
- // CHECK: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1
- // CHECK: [[ADJ:%.*]] = sub nsw i64 [[TMPADJ]], 16
- // CHECK: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1
- // CHECK: store { i64, i64 } [[RES]], { i64, i64 }* @pa, align 8
+ // CODE-LP64: [[TMP:%.*]] = load { i64, i64 }* @pc, align 8
+ // CODE-LP64: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1
+ // CODE-LP64: [[ADJ:%.*]] = sub nsw i64 [[TMPADJ]], 16
+ // CODE-LP64: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1
+ // CODE-LP64: store { i64, i64 } [[RES]], { i64, i64 }* @pa, align 8
pa = static_cast<void (A::*)()>(pc);
}
void f2() {
- // CHECK: store { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }
+ // CODE-LP64: store { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }
void (A::*pa2)() = &A::f;
- // CHECK: store { i64, i64 } { i64 1, i64 0 }
- // CHECK-LP32: store { i32, i32 } { i32 1, i32 0 }
+ // CODE-LP64: store { i64, i64 } { i64 1, i64 0 }
+ // CODE-LP32: store { i32, i32 } { i32 1, i32 0 }
void (A::*pa3)() = &A::vf1;
- // CHECK: store { i64, i64 } { i64 9, i64 0 }
- // CHECK-LP32: store { i32, i32 } { i32 5, i32 0 }
+ // CODE-LP64: store { i64, i64 } { i64 9, i64 0 }
+ // CODE-LP32: store { i32, i32 } { i32 5, i32 0 }
void (A::*pa4)() = &A::vf2;
}
@@ -195,12 +187,12 @@
struct B { void foo(); virtual void vfoo(); };
struct C : A, B { void foo(); virtual void vfoo(); };
- // CHECK-ARM: @_ZN5test74ptr0E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71A3fooEv to i32), i32 0 }
- // CHECK-ARM: @_ZN5test74ptr1E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71B3fooEv to i32), i32 8 }
- // CHECK-ARM: @_ZN5test74ptr2E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71C3fooEv to i32), i32 0 }
- // CHECK-ARM: @_ZN5test74ptr3E = global {{.*}} { i32 0, i32 1 }
- // CHECK-ARM: @_ZN5test74ptr4E = global {{.*}} { i32 0, i32 9 }
- // CHECK-ARM: @_ZN5test74ptr5E = global {{.*}} { i32 0, i32 1 }
+ // GLOBAL-ARM: @_ZN5test74ptr0E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71A3fooEv to i32), i32 0 }
+ // GLOBAL-ARM: @_ZN5test74ptr1E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71B3fooEv to i32), i32 8 }
+ // GLOBAL-ARM: @_ZN5test74ptr2E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71C3fooEv to i32), i32 0 }
+ // GLOBAL-ARM: @_ZN5test74ptr3E = global {{.*}} { i32 0, i32 1 }
+ // GLOBAL-ARM: @_ZN5test74ptr4E = global {{.*}} { i32 0, i32 9 }
+ // GLOBAL-ARM: @_ZN5test74ptr5E = global {{.*}} { i32 0, i32 1 }
void (C::*ptr0)() = &A::foo;
void (C::*ptr1)() = &B::foo;
void (C::*ptr2)() = &C::foo;
@@ -234,9 +226,9 @@
fooptr p;
};
- // CHECK: define void @_ZN5test94testEv(
- // CHECK: alloca i32
- // CHECK-NEXT: ret void
+ // CODE-LP64: define void @_ZN5test94testEv(
+ // CODE-LP64: alloca i32
+ // CODE-LP64-NEXT: ret void
void test() {
int x;
static S array[] = { (fooptr) &B::foo };
@@ -261,14 +253,37 @@
virtual void requireNonZeroAdjustment();
};
- // Non-ARM tests at top of file.
+
+// It's not that the offsets are doubled on ARM, it's that they're left-shifted by 1.
+
+// GLOBAL-LP64: @_ZN6test101aE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 0 }, align 8
+// GLOBAL-LP32: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4
+// GLOBAL-ARM: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4
void (A::*a)() = &A::foo;
+
+// GLOBAL-LP64: @_ZN6test101bE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8
+// GLOBAL-LP32: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4
+// GLOBAL-ARM: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
void (B::*b)() = (void (B::*)()) &A::foo;
+
+// GLOBAL-LP64: @_ZN6test101cE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8
+// GLOBAL-LP32: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4
+// GLOBAL-ARM: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
void (C::*c)() = (void (C::*)()) (void (B::*)()) &A::foo;
+
+// GLOBAL-LP64: @_ZN6test101dE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 16 }, align 8
+// GLOBAL-LP32: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
+// GLOBAL-ARM: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 16 }, align 4
void (D::*d)() = (void (C::*)()) (void (B::*)()) &A::foo;
}
-// It's not that the offsets are doubled on ARM, it's that they're left-shifted by 1.
-// CHECK-ARM: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4
-// CHECK-ARM: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
-// CHECK-ARM: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4
-// CHECK-ARM: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 16 }, align 4
+
+namespace test11 {
+ struct A { virtual void a(); };
+ struct B : A {};
+ struct C : B { virtual void a(); };
+ void (C::*x)() = &C::a;
+
+ // GLOBAL-LP64: @_ZN6test111xE = global { i64, i64 } { i64 1, i64 0 }
+ // GLOBAL-LP32: @_ZN6test111xE = global { i32, i32 } { i32 1, i32 0 }
+ // GLOBAL-ARM: @_ZN6test111xE = global { i32, i32 } { i32 0, i32 1 }
+}
Modified: cfe/branches/tooling/test/CodeGenCXX/member-init-anon-union.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/member-init-anon-union.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/member-init-anon-union.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/member-init-anon-union.cpp Tue May 8 03:47:31 2012
@@ -2,8 +2,10 @@
// PR10531.
+int make_a();
+
static union {
- int a = 42;
+ int a = make_a();
char *b;
};
@@ -32,4 +34,4 @@
// CHECK: define {{.*}}@"[[CONSTRUCT_GLOBAL]]C2Ev"
// CHECK-NOT: }
-// CHECK: store i32 42
+// CHECK: call {{.*}}@_Z6make_a
Removed: cfe/branches/tooling/test/CodeGenCXX/member-pointer-type-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/member-pointer-type-convert.cpp?rev=156377&view=auto
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/member-pointer-type-convert.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/member-pointer-type-convert.cpp (removed)
@@ -1,11 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
-
-struct A;
-typedef int A::*param_t;
-struct {
- const char *name;
- param_t par;
-} *ptr;
-void test_ptr() { (void) ptr; } // forced use
-
-// CHECK: type { i8*, {{i..}} }
Removed: cfe/branches/tooling/test/CodeGenCXX/virt-call-offsets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/virt-call-offsets.cpp?rev=156377&view=auto
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/virt-call-offsets.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/virt-call-offsets.cpp (removed)
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
-
-struct A { virtual void a(); };
-struct B : A {};
-struct C : B { virtual void a(); };
-void (C::*x)() = &C::a;
-
-// CHECK: @x = global { i{{[0-9]+}}, i{{[0-9]+}} } { i{{[0-9]+}} 1, i{{[0-9]+}} 0 }
Removed: cfe/branches/tooling/test/CodeGenCXX/x86-64-abi-sret-vs-2word-struct-param.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/x86-64-abi-sret-vs-2word-struct-param.cpp?rev=156377&view=auto
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/x86-64-abi-sret-vs-2word-struct-param.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/x86-64-abi-sret-vs-2word-struct-param.cpp (removed)
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
-// XTARGET: x86
-// PR4242
-// (PR 4242 bug is on 64-bit only, test passes on x86-32 as well)
-
-struct S {
- void* data[3];
-};
-
-struct T {
- void* data[2];
-};
-
-// CHECK: %struct.T* byval
-extern "C" S fail(int, int, int, int, T t, void* p) {
- S s;
- s.data[0] = t.data[0];
- s.data[1] = t.data[1];
- s.data[2] = p;
- return s;
-}
-
-// CHECK: %struct.T* byval
-extern "C" S* succeed(S* sret, int, int, int, int, T t, void* p) {
- sret->data[0] = t.data[0];
- sret->data[1] = t.data[1];
- sret->data[2] = p;
- return sret;
-}
Modified: cfe/branches/tooling/test/CodeGenCXX/x86_64-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenCXX/x86_64-arguments.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenCXX/x86_64-arguments.cpp (original)
+++ cfe/branches/tooling/test/CodeGenCXX/x86_64-arguments.cpp Tue May 8 03:47:31 2012
@@ -56,6 +56,7 @@
// CHECK: define <2 x float> @_ZN6PR77423fooEPNS_2c2E(%"struct.PR7742::c2"* %P)
c2 foo(c2 *P) {
+ return c2();
}
}
@@ -149,3 +150,34 @@
foo(b);
}
}
+
+// PR4242
+namespace test9 {
+ // Large enough to be passed indirectly.
+ struct S { void *data[3]; };
+
+ struct T { void *data[2]; };
+
+ // CHECK: define void @_ZN5test93fooEPNS_1SEPNS_1TE([[S:%.*]]*, [[T:%.*]]*)
+ void foo(S*, T*) {}
+
+ // CHECK: define void @_ZN5test91aEiiiiNS_1TEPv([[S]]* noalias sret {{%.*}}, i32, i32, i32, i32, [[T]]* byval align 8, i8*)
+ S a(int, int, int, int, T, void*) {
+ return S();
+ }
+
+ // CHECK: define [[S]]* @_ZN5test91bEPNS_1SEiiiiNS_1TEPv([[S]]* {{%.*}}, i32, i32, i32, i32, [[T:%.*]]* byval align 8, i8*)
+ S* b(S* sret, int, int, int, int, T, void*) {
+ return sret;
+ }
+
+ // CHECK: define void @_ZN5test91cEiiiNS_1TEPv([[S]]* noalias sret {{%.*}}, i32, i32, i32, i8* {{%.*}}, i8* {{%.*}}, i8*)
+ S c(int, int, int, T, void*) {
+ return S();
+ }
+
+ // CHECK: define [[S]]* @_ZN5test91dEPNS_1SEiiiNS_1TEPv([[S]]* {{%.*}}, i32, i32, i32, i8* {{%.*}}, i8* {{%.*}}, i8*)
+ S* d(S* sret, int, int, int, T, void*) {
+ return sret;
+ }
+}
Modified: cfe/branches/tooling/test/CodeGenObjCXX/encode.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/CodeGenObjCXX/encode.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/CodeGenObjCXX/encode.mm (original)
+++ cfe/branches/tooling/test/CodeGenObjCXX/encode.mm Tue May 8 03:47:31 2012
@@ -187,3 +187,17 @@
class CefBrowserImpl2 : public CefBrowser2 {};
// CHECK: @_ZL2g7 = internal constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00"
const char g7[] = @encode(CefBrowserImpl2);
+
+// <rdar://problem/11324167>
+struct Empty {};
+
+struct X : Empty {
+ int array[10];
+};
+
+struct Y : Empty {
+ X vec;
+};
+
+// CHECK: @_ZL2g8 = internal constant [14 x i8] c"{Y={X=[10i]}}\00"
+const char g8[] = @encode(Y);
Modified: cfe/branches/tooling/test/Driver/altivec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/altivec.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/altivec.cpp (original)
+++ cfe/branches/tooling/test/Driver/altivec.cpp Tue May 8 03:47:31 2012
@@ -1,6 +1,6 @@
// Check that we error when -faltivec is specified on non-ppc platforms.
-// RUN: %clang -ccc-clang-archs powerpc -target powerpc-apple-darwin -faltivec -fsyntax-only %s
+// RUN: %clang -ccc-clang-archs powerpc -target powerpc-unk-unk -faltivec -fsyntax-only %s
// RUN: %clang -ccc-clang-archs powerpc64 -target powerpc64-linux-gnu -faltivec -fsyntax-only %s
// RUN: %clang -target i386-pc-win32 -faltivec -fsyntax-only %s 2>&1 | FileCheck %s
Modified: cfe/branches/tooling/test/Driver/debug-options-as.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/debug-options-as.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/debug-options-as.c (original)
+++ cfe/branches/tooling/test/Driver/debug-options-as.c Tue May 8 03:47:31 2012
@@ -4,7 +4,8 @@
// Check to make sure clang is somewhat picky about -g options.
// (Delived from debug-options.c)
// rdar://10383444
-// RUN: %clang -### -c -save-temps -g %s 2>&1 | FileCheck -check-prefix=SAVE %s
+// RUN: %clang -### -c -save-temps -integrated-as -g %s 2>&1 \
+// RUN: | FileCheck -check-prefix=SAVE %s
//
// SAVE: "-cc1as"
// SAVE-NOT: "-g"
@@ -12,7 +13,8 @@
// Check to make sure clang with -g on a .s file gets passed.
// rdar://9275556
// RUN: touch %t.s
-// RUN: %clang -### -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
+// RUN: %clang -### -c -integrated-as -g %t.s 2>&1 \
+// RUN: | FileCheck -check-prefix=S %s
//
// S: "-cc1as"
// S: "-g"
Modified: cfe/branches/tooling/test/Driver/debug-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/debug-options.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/debug-options.c (original)
+++ cfe/branches/tooling/test/Driver/debug-options.c Tue May 8 03:47:31 2012
@@ -7,6 +7,8 @@
// RUN: %clang -### -c -ganything %s 2>&1 | FileCheck -check-prefix=GANY %s
// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=GGDB %s
// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=GFOO %s
+// RUN: %clang -### -c -gline-tables-only %s 2>&1 \
+// RUN: | FileCheck -check-prefix=GLTO %s
//
// G: "-cc1"
// G: "-g"
@@ -25,3 +27,6 @@
//
// GFOO: "-cc1"
// GFOO-NOT: "-g"
+//
+// GLTO: "-cc1"
+// GLTO: "-g"
Modified: cfe/branches/tooling/test/Driver/fast-math.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/fast-math.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/fast-math.c (original)
+++ cfe/branches/tooling/test/Driver/fast-math.c Tue May 8 03:47:31 2012
@@ -4,6 +4,9 @@
// LLVM only supports three switches which is more coarse grained than GCC's
// support.
//
+// Both of them use gcc driver for as.
+// XFAIL: cygwin,mingw32
+//
// RUN: %clang -### -fno-honor-infinities -c %s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s
// CHECK-NO-INFS: "-cc1"
@@ -23,6 +26,14 @@
// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
// RUN: %clang -### -target i686-apple-darwin -c %s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-unknown-freebsd -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-unknown-netbsd -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-unknown-openbsd -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-unknown-dragonfly -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
// CHECK-NO-MATH-ERRNO: "-cc1"
// CHECK-NO-MATH-ERRNO-NOT: "-fmath-errno"
//
Modified: cfe/branches/tooling/test/Driver/linux-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Driver/linux-ld.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Driver/linux-ld.c (original)
+++ cfe/branches/tooling/test/Driver/linux-ld.c Tue May 8 03:47:31 2012
@@ -291,6 +291,28 @@
// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.."
// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/lib"
// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target mips64-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64 %s
+// CHECK-DEBIAN-MIPS64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-MIPS64: "{{.*}}/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o"
+// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/64"
+// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5"
+// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target mips64el-linux-gnu \
+// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64EL %s
+// CHECK-DEBIAN-MIPS64EL: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-MIPS64EL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o"
+// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/64"
+// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5"
+// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.."
+// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib"
//
// Test linker invocation on Android.
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
Modified: cfe/branches/tooling/test/FixIt/fixit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/FixIt/fixit.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/FixIt/fixit.cpp (original)
+++ cfe/branches/tooling/test/FixIt/fixit.cpp Tue May 8 03:47:31 2012
@@ -205,19 +205,21 @@
template<typename> struct Baz> // expected-error {{template template parameter requires 'class' after the parameter list}}
void func();
-
namespace ShadowedTagType {
class Foo {
public:
enum Bar { X, Y };
void SetBar(Bar bar);
- Bar Bar();
+ Bar Bar(); // expected-note 2 {{enum 'Bar' is hidden by a non-type declaration of 'Bar' here}}
private:
Bar bar_; // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}}
};
void Foo::SetBar(Bar bar) { bar_ = bar; } // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}}
}
+#define NULL __null
+char c = NULL; // expected-warning {{implicit conversion of NULL constant to 'char'}}
+
namespace arrow_suggest {
template <typename T>
Removed: cfe/branches/tooling/test/Headers/ms-intrin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Headers/ms-intrin.c?rev=156377&view=auto
==============================================================================
--- cfe/branches/tooling/test/Headers/ms-intrin.c (original)
+++ cfe/branches/tooling/test/Headers/ms-intrin.c (removed)
@@ -1,11 +0,0 @@
-// RUN: %clang -fsyntax-only -ffreestanding -target i686-pc-win32 %s
-// RUN: %clangxx -fsyntax-only -ffreestanding -target i686-pc-win32 -x c++ %s
-
-#include <intrin.h>
-
-// Ensure we're compiling in MS-compat mode.
-__declspec(naked) void f();
-
-// Ensure that we got various fundamental headers.
-// FIXME: We could probably do more extensive testing here.
-size_t test = 0;
Modified: cfe/branches/tooling/test/Index/c-index-api-loadTU-test.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/c-index-api-loadTU-test.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/c-index-api-loadTU-test.m (original)
+++ cfe/branches/tooling/test/Index/c-index-api-loadTU-test.m Tue May 8 03:47:31 2012
@@ -83,7 +83,7 @@
// CHECK: <invalid loc>:0:0: attribute(ibaction)=
// CHECK: c-index-api-loadTU-test.m:8:50: ParmDecl=msg:8:50 (Definition) Extent=[8:47 - 8:53]
// CHECK: c-index-api-loadTU-test.m:8:47: TypeRef=id:0:0 Extent=[8:47 - 8:49]
-// CHECK: c-index-api-loadTU-test.m:9:3: ObjCInstanceMethodDecl=foo:9:3 (deprecated) Extent=[9:1 - 9:35]
+// CHECK: c-index-api-loadTU-test.m:9:3: ObjCInstanceMethodDecl=foo:9:3 (deprecated) (always deprecated: "") Extent=[9:1 - 9:35]
// CHECK: c-index-api-loadTU-test.m:10:3: ObjCClassMethodDecl=fooC:10:3 Extent=[10:1 - 10:8]
// CHECK: c-index-api-loadTU-test.m:14:12: ObjCInterfaceDecl=Bar:14:12 Extent=[14:1 - 18:5]
// CHECK: c-index-api-loadTU-test.m:14:18: ObjCSuperClassRef=Foo:4:12 Extent=[14:18 - 14:21]
Modified: cfe/branches/tooling/test/Index/complete-with-annotations.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/complete-with-annotations.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/complete-with-annotations.cpp (original)
+++ cfe/branches/tooling/test/Index/complete-with-annotations.cpp Tue May 8 03:47:31 2012
@@ -14,7 +14,7 @@
}
// CHECK: CXXMethod:{ResultType void}{TypedText doSomething}{LeftParen (}{RightParen )} (34)
-// CHECK: FieldDecl:{ResultType int}{TypedText field} (35) ("three", "two", "one")
+// CHECK: FieldDecl:{ResultType int}{TypedText field} (35) ("one", "two", "three")
// CHECK: CXXMethod:{ResultType void}{TypedText func2}{LeftParen (}{RightParen )} (34) ("some annotation")
// CHECK: FieldDecl:{ResultType int}{TypedText member2} (35) ("another annotation", "some annotation")
// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (34)
Modified: cfe/branches/tooling/test/Index/print-typekind.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Index/print-typekind.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Index/print-typekind.m (original)
+++ cfe/branches/tooling/test/Index/print-typekind.m Tue May 8 03:47:31 2012
@@ -1,10 +1,10 @@
@interface Foo
@property (readonly) id x;
-(int) mymethod;
--(int) mymethod2:(int)x blah:(float)y;
+-(int) mymethod2:(id)x blah:(Class)y boo:(SEL)z;
@end
// RUN: c-index-test -test-print-typekind %s | FileCheck %s
-// CHECK: ObjCPropertyDecl=x:2:25 typekind=Typedef [canonical=ObjCObjectPointer]
+// CHECK: ObjCPropertyDecl=x:2:25 typekind=ObjCId [canonical=ObjCObjectPointer]
// CHECK: ObjCInstanceMethodDecl=mymethod:3:8 typekind=Invalid [result=Int]
-// CHECK: ObjCInstanceMethodDecl=mymethod2:blah::4:8 typekind=Invalid [result=Int] [args= Int Float]
+// CHECK: ObjCInstanceMethodDecl=mymethod2:blah:boo::4:8 typekind=Invalid [result=Int] [args= ObjCId ObjCClass ObjCSel]
Modified: cfe/branches/tooling/test/Misc/warning-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/warning-flags.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Misc/warning-flags.c (original)
+++ cfe/branches/tooling/test/Misc/warning-flags.c Tue May 8 03:47:31 2012
@@ -17,7 +17,7 @@
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (253):
+CHECK: Warnings without flags (245):
CHECK-NEXT: ext_anonymous_struct_union_qualified
CHECK-NEXT: ext_binary_literal
CHECK-NEXT: ext_cast_fn_obj
@@ -112,9 +112,6 @@
CHECK-NEXT: warn_attribute_weak_on_field
CHECK-NEXT: warn_attribute_weak_on_local
CHECK-NEXT: warn_attribute_wrong_decl_type
-CHECK-NEXT: warn_availability_and_unavailable
-CHECK-NEXT: warn_availability_unknown_platform
-CHECK-NEXT: warn_availability_version_ordering
CHECK-NEXT: warn_bad_receiver_type
CHECK-NEXT: warn_bitfield_width_exceeds_type_size
CHECK-NEXT: warn_bool_switch_condition
@@ -133,9 +130,7 @@
CHECK-NEXT: warn_conv_to_base_not_used
CHECK-NEXT: warn_conv_to_self_not_used
CHECK-NEXT: warn_conv_to_void_not_used
-CHECK-NEXT: warn_cxx0x_right_shift_in_template_arg
CHECK-NEXT: warn_delete_array_type
-CHECK-NEXT: warn_division_by_zero
CHECK-NEXT: warn_double_const_requires_fp64
CHECK-NEXT: warn_drv_assuming_mfloat_abi_is
CHECK-NEXT: warn_drv_clang_unsupported
@@ -193,8 +188,6 @@
CHECK-NEXT: warn_ns_attribute_wrong_return_type
CHECK-NEXT: warn_objc_object_attribute_wrong_type
CHECK-NEXT: warn_objc_property_copy_missing_on_block
-CHECK-NEXT: warn_objc_property_default_assign_on_object
-CHECK-NEXT: warn_objc_property_no_assignment_attribute
CHECK-NEXT: warn_objc_protocol_qualifier_missing_id
CHECK-NEXT: warn_octal_escape_too_large
CHECK-NEXT: warn_odr_tag_type_inconsistent
@@ -244,7 +237,6 @@
CHECK-NEXT: warn_register_objc_catch_parm
CHECK-NEXT: warn_related_result_type_compatibility_class
CHECK-NEXT: warn_related_result_type_compatibility_protocol
-CHECK-NEXT: warn_remainder_by_zero
CHECK-NEXT: warn_root_inst_method_not_found
CHECK-NEXT: warn_second_parameter_of_va_start_not_last_named_argument
CHECK-NEXT: warn_second_parameter_to_va_arg_never_compatible
Removed: cfe/branches/tooling/test/Misc/wnull-character.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Misc/wnull-character.cpp?rev=156377&view=auto
==============================================================================
Binary files cfe/branches/tooling/test/Misc/wnull-character.cpp (original) and cfe/branches/tooling/test/Misc/wnull-character.cpp (removed) differ
Modified: cfe/branches/tooling/test/PCH/objc_methods.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/PCH/objc_methods.h?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/PCH/objc_methods.h (original)
+++ cfe/branches/tooling/test/PCH/objc_methods.h Tue May 8 03:47:31 2012
@@ -9,3 +9,33 @@
// FIXME: @compatibility_alias AliasForTestPCH TestPCH;
+// http://llvm.org/PR12689
+ at interface PR12689
+ at end
+
+ at implementation PR12689
+-(void)mugi:(int)x {
+ switch(x) {
+ case 23: {}
+ }
+}
+-(void)bonk:(int)x {
+ switch(x) {
+ case 42: {}
+ }
+}
+ at end
+
+ at interface PR12689_2
+ at end
+
+ at implementation PR12689_2
+-(void)mugi:(int)x {
+ switch(x) {
+ case 23: [self bonk:x]; break;
+ case 82: break;
+ }
+}
+-(void)bonk:(int)x {
+}
+ at end
Modified: cfe/branches/tooling/test/Parser/cxx-using-declaration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/cxx-using-declaration.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/cxx-using-declaration.cpp (original)
+++ cfe/branches/tooling/test/Parser/cxx-using-declaration.cpp Tue May 8 03:47:31 2012
@@ -43,3 +43,19 @@
// Should have some errors here. Waiting for implementation.
void X(int);
struct X *x;
+
+
+namespace ShadowedTagNotes {
+
+namespace foo {
+ class Bar {};
+}
+
+void Bar(int); // expected-note{{class 'Bar' is hidden by a non-type declaration of 'Bar' here}}
+using foo::Bar;
+
+void ambiguity() {
+ const Bar *x; // expected-error{{must use 'class' tag to refer to type 'Bar' in this scope}}
+}
+
+} // namespace ShadowedTagNotes
Modified: cfe/branches/tooling/test/Parser/declarators.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/declarators.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/declarators.c (original)
+++ cfe/branches/tooling/test/Parser/declarators.c Tue May 8 03:47:31 2012
@@ -100,3 +100,10 @@
void test16(i) int i j; { } // expected-error {{expected ';' at end of declaration}}
void test17(i, j) int i, j k; { } // expected-error {{expected ';' at end of declaration}}
+
+
+// PR12595
+void test18() {
+ int x = 4+(5-12)); // expected-error {{extraneous ')' before ';'}}
+}
+
Modified: cfe/branches/tooling/test/Parser/recovery.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Parser/recovery.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Parser/recovery.c (original)
+++ cfe/branches/tooling/test/Parser/recovery.c Tue May 8 03:47:31 2012
@@ -37,8 +37,9 @@
test(0);
else
;
-
- if (x.i == 0)) // expected-error {{expected expression}}
+
+ // PR12595
+ if (x.i == 0)) // expected-error {{extraneous ')' after condition, expected a statement}}
test(0);
else
;
Modified: cfe/branches/tooling/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Preprocessor/init.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Preprocessor/init.c (original)
+++ cfe/branches/tooling/test/Preprocessor/init.c Tue May 8 03:47:31 2012
@@ -62,12 +62,21 @@
//
// RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -check-prefix FREESTANDING %s
// FREESTANDING:#define __STDC_HOSTED__ 0
-//
+//
+//
+// RUN: %clang_cc1 -x c++ -std=gnu++11 -E -dM < /dev/null | FileCheck -check-prefix GXX11 %s
+//
+// GXX11:#define __GNUG__
+// GXX11:#define __GXX_WEAK__ 1
+// GXX11:#define __cplusplus 201103L
+// GXX11:#define __private_extern__ extern
+//
+//
// RUN: %clang_cc1 -x c++ -std=gnu++98 -E -dM < /dev/null | FileCheck -check-prefix GXX98 %s
//
// GXX98:#define __GNUG__
// GXX98:#define __GXX_WEAK__ 1
-// GXX98:#define __cplusplus 1
+// GXX98:#define __cplusplus 199711L
// GXX98:#define __private_extern__ extern
//
//
Modified: cfe/branches/tooling/test/Rewriter/objc-bool-literal-modern-1.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/objc-bool-literal-modern-1.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/objc-bool-literal-modern-1.mm (original)
+++ cfe/branches/tooling/test/Rewriter/objc-bool-literal-modern-1.mm Tue May 8 03:47:31 2012
@@ -2,6 +2,9 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"__declspec(X)=" %t-rw.cpp
// rdar://11231426
+// rdar://11375908
+typedef unsigned long size_t;
+
typedef bool BOOL;
BOOL yes() {
Modified: cfe/branches/tooling/test/Rewriter/objc-modern-boxing.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/objc-modern-boxing.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/objc-modern-boxing.mm (original)
+++ cfe/branches/tooling/test/Rewriter/objc-modern-boxing.mm Tue May 8 03:47:31 2012
@@ -1,11 +1,7 @@
// RUN: %clang_cc1 -E %s -o %t.mm
// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp -Wno-attributes
-
-// FIXME: It is incompatible to mingw due to __declspec.
-// See also r155278
-// XFAIL: mingw32
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp -Wno-attributes
extern char *strdup(const char *str);
extern "C" void *sel_registerName(const char *);
Modified: cfe/branches/tooling/test/Rewriter/objc-modern-property-attributes.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/objc-modern-property-attributes.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/objc-modern-property-attributes.mm (original)
+++ cfe/branches/tooling/test/Rewriter/objc-modern-property-attributes.mm Tue May 8 03:47:31 2012
@@ -33,3 +33,13 @@
// CHECK: T@?,C,V__completion
// CHECK: T@\"PropertyClass\",&,VYVAR
+ at interface Test @end
+ at interface Test (Category)
+ at property int q;
+ at end
+
+ at implementation Test (Category)
+ at dynamic q;
+ at end
+
+// CHECK: {{"q","Ti,D"}}
Modified: cfe/branches/tooling/test/Rewriter/rewrite-block-literal-1.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-block-literal-1.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-block-literal-1.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-block-literal-1.mm Tue May 8 03:47:31 2012
@@ -5,6 +5,9 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
// rdar://11259664
+// rdar://11375908
+typedef unsigned long size_t;
+
void *sel_registerName(const char *);
typedef void (^BLOCK_TYPE)(void);
Modified: cfe/branches/tooling/test/Rewriter/rewrite-block-literal.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-block-literal.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-block-literal.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-block-literal.mm Tue May 8 03:47:31 2012
@@ -5,6 +5,9 @@
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// rdar://11375908
+typedef unsigned long size_t;
+
// rdar: // 11006566
void I( void (^)(void));
Modified: cfe/branches/tooling/test/Rewriter/rewrite-block-pointer.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-block-pointer.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-block-pointer.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-block-pointer.mm Tue May 8 03:47:31 2012
@@ -4,6 +4,9 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
// radar 7638400
+// rdar://11375908
+typedef unsigned long size_t;
+
typedef void * id;
void *sel_registerName(const char *);
Modified: cfe/branches/tooling/test/Rewriter/rewrite-byref-in-nested-blocks.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-byref-in-nested-blocks.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-byref-in-nested-blocks.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-byref-in-nested-blocks.mm Tue May 8 03:47:31 2012
@@ -1,9 +1,12 @@
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-modern-rw.cpp
// radar 7692350
+// rdar://11375908
+typedef unsigned long size_t;
+
void f(void (^block)(void));
@interface X {
Modified: cfe/branches/tooling/test/Rewriter/rewrite-foreach-in-block.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-foreach-in-block.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-foreach-in-block.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-foreach-in-block.mm Tue May 8 03:47:31 2012
@@ -4,6 +4,8 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
// rdar:// 9878420
+typedef unsigned long size_t;
+
void objc_enumerationMutation(id);
void *sel_registerName(const char *);
typedef void (^CoreDAVCompletionBlock)(void);
Modified: cfe/branches/tooling/test/Rewriter/rewrite-modern-block-consts.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-modern-block-consts.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-modern-block-consts.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-modern-block-consts.mm Tue May 8 03:47:31 2012
@@ -1,7 +1,10 @@
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"__declspec(X)=" %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -U__declspec -D"__declspec(X)=" %t-modern-rw.cpp
// rdar:// 8243071
+// rdar://11375908
+typedef unsigned long size_t;
+
void x(int y) {}
void f() {
const int bar = 3;
Modified: cfe/branches/tooling/test/Rewriter/rewrite-modern-block.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-modern-block.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-modern-block.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-modern-block.mm Tue May 8 03:47:31 2012
@@ -1,7 +1,8 @@
// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
// rdar://11230308
+typedef unsigned long size_t;
typedef struct {
char byte0;
char byte1;
@@ -46,3 +47,19 @@
return BI2;
}
+// rdar://11326988
+typedef struct _z {
+ int location;
+ int length;
+} z;
+
+z w(int loc, int len);
+
+ at interface rdar11326988
+ at end
+ at implementation rdar11326988
+- (void)y:(int)options {
+ __attribute__((__blocks__(byref))) z firstRange = w(1, 0);
+ options &= ~(1 | 2);
+}
+ at end
Modified: cfe/branches/tooling/test/Rewriter/rewrite-modern-extern-c-func-decl.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-modern-extern-c-func-decl.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-modern-extern-c-func-decl.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-modern-extern-c-func-decl.mm Tue May 8 03:47:31 2012
@@ -1,10 +1,8 @@
-// RUN: %clang_cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks -o %t-rw.cpp %s
-// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fms-extensions -U__declspec -rewrite-objc -x objective-c++ -fblocks -o %t-rw.cpp %s
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
// rdar://11131490
-// XFAIL: mingw
-// FIXME: __declspec(X) is predefined on mingw.
-
+typedef unsigned long size_t;
extern "C" __declspec(dllexport) void BreakTheRewriter(void) {
__block int aBlockVariable = 0;
void (^aBlock)(void) = ^ {
Modified: cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-1.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-1.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-1.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-modern-ivars-1.mm Tue May 8 03:47:31 2012
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
@interface NSCheapMutableString {
@private
@@ -87,3 +87,38 @@
}
@end
+enum OUTSIDE {
+ yes
+};
+
+ at interface MoreEnumTests {
+ at private
+ enum INSIDE {
+ no
+ } others;
+
+ enum OUTSIDE meetoo;
+
+ enum {
+ one,
+ two
+ } eu;
+}
+ at end
+
+ at interface I {
+ enum INSIDE I1;
+ enum OUTSIDE I2;
+ enum ALSO_INSIDE {
+ maybe
+ } I3;
+
+ enum ALSO_INSIDE I4;
+
+ enum {
+ three,
+ four
+ } I5;
+}
+ at end
+
Modified: cfe/branches/tooling/test/Rewriter/rewrite-modern-struct-ivar.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-modern-struct-ivar.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-modern-struct-ivar.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-modern-struct-ivar.mm Tue May 8 03:47:31 2012
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -E %s -o %t.mm
// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.mm -o %t-rw.cpp
// RUN: FileCheck --input-file=%t-rw.cpp %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
struct S {
int i1;
@@ -20,5 +20,33 @@
@implementation I
- (struct S) dMeth{ return struct_ivar; }
@end
-
+
// CHECK: return (*(struct S *)((char *)self + OBJC_IVAR_$_I$struct_ivar));
+
+// rdar://11323187
+ at interface Foo{
+ @protected
+ struct {
+ int x:1;
+ int y:1;
+ } bar;
+
+ struct _S {
+ int x:1;
+ int y:1;
+ } s;
+
+}
+ at end
+ at implementation Foo
+- (void)x {
+ bar.x = 0;
+ bar.y = 1;
+
+ s.x = 0;
+ s.y = 1;
+}
+ at end
+
+// CHECK: (*(decltype(((Foo_IMPL *)0U)->bar) *)((char *)self + OBJC_IVAR_$_Foo$bar)).x = 0;
+// CHECK: (*(struct _S *)((char *)self + OBJC_IVAR_$_Foo$s)).x = 0;
Modified: cfe/branches/tooling/test/Rewriter/rewrite-modern-typeof.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-modern-typeof.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-modern-typeof.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-modern-typeof.mm Tue May 8 03:47:31 2012
@@ -2,6 +2,7 @@
// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+typedef unsigned long size_t;
extern "C" {
extern "C" void *_Block_copy(const void *aBlock);
extern "C" void _Block_release(const void *aBlock);
Modified: cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks-1.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks-1.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks-1.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks-1.mm Tue May 8 03:47:31 2012
@@ -4,6 +4,7 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
// radar 7696893
+typedef unsigned long size_t;
void *sel_registerName(const char *);
void f(void (^block)(void));
Modified: cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks-2.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks-2.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks-2.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks-2.mm Tue May 8 03:47:31 2012
@@ -6,6 +6,7 @@
// grep "static void __FUNC_block_copy_" %t-modern-rw.cpp | count 2
// rdar://8499592
+typedef unsigned long size_t;
void Outer(void (^bk)());
void Inner(void (^bk)());
void INNER_FUNC(id d);
Modified: cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-nested-blocks.mm Tue May 8 03:47:31 2012
@@ -5,6 +5,7 @@
// radar 7682149
+typedef unsigned long size_t;
void f(void (^block)(void));
@interface X {
Modified: cfe/branches/tooling/test/Rewriter/rewrite-nested-property-in-blocks.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-nested-property-in-blocks.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-nested-property-in-blocks.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-nested-property-in-blocks.mm Tue May 8 03:47:31 2012
@@ -4,6 +4,7 @@
// RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
// radar 8608293
+typedef unsigned long size_t;
void *sel_registerName(const char *);
extern "C" void nowarn(id);
Modified: cfe/branches/tooling/test/Rewriter/rewrite-rewritten-initializer.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-rewritten-initializer.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-rewritten-initializer.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-rewritten-initializer.mm Tue May 8 03:47:31 2012
@@ -1,9 +1,10 @@
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp
-// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw-modern.cpp
+// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw-modern.cpp
// radar 7669784
+typedef unsigned long size_t;
typedef void * id;
void *sel_registerName(const char *);
Modified: cfe/branches/tooling/test/Rewriter/rewrite-unique-block-api.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Rewriter/rewrite-unique-block-api.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Rewriter/rewrite-unique-block-api.mm (original)
+++ cfe/branches/tooling/test/Rewriter/rewrite-unique-block-api.mm Tue May 8 03:47:31 2012
@@ -4,6 +4,7 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
// radar 7630551
+typedef unsigned long size_t;
void f(void (^b)(char c));
@interface a
Modified: cfe/branches/tooling/test/Sema/128bitint.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/128bitint.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/128bitint.c (original)
+++ cfe/branches/tooling/test/Sema/128bitint.c Tue May 8 03:47:31 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 -fms-extensions %s
typedef int i128 __attribute__((__mode__(TI)));
typedef unsigned u128 __attribute__((__mode__(TI)));
@@ -11,3 +11,10 @@
// PR11916: Support for libstdc++ 4.7
__int128 i = (__int128)0;
unsigned __int128 u = (unsigned __int128)-1;
+
+long long SignedTooBig = 123456789012345678901234567890; // expected-warning {{integer constant is too large for its type}}
+__int128_t Signed128 = 123456789012345678901234567890i128;
+long long Signed64 = 123456789012345678901234567890i128; // expected-warning {{implicit conversion from '__int128' to 'long long' changes value from 123456789012345678901234567890 to -4362896299872285998}}
+unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-warning {{integer constant is too large for its type}}
+__uint128_t Unsigned128 = 123456789012345678901234567890Ui128;
+unsigned long long Unsigned64 = 123456789012345678901234567890Ui128; // expected-warning {{implicit conversion from 'unsigned __int128' to 'unsigned long long' changes value from 123456789012345678901234567890 to 14083847773837265618}}
Modified: cfe/branches/tooling/test/Sema/annotate.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/annotate.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/annotate.c (original)
+++ cfe/branches/tooling/test/Sema/annotate.c Tue May 8 03:47:31 2012
@@ -4,7 +4,8 @@
__attribute__((annotate("bar"))) int x;
__attribute__((annotate(1))) int y; // expected-error {{argument to annotate attribute was not a string literal}}
__attribute__((annotate("bar", 1))) int z; // expected-error {{attribute takes one argument}}
- int u = __builtin_annotation(z, (char*) 0); // expected-error {{__builtin_annotation requires a non wide string constant}}
- int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{__builtin_annotation requires a non wide string constant}}
+ int u = __builtin_annotation(z, (char*) 0); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}}
+ int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}}
int w = __builtin_annotation(z, "foo");
+ float b = __builtin_annotation(*a, "foo"); // expected-error {{first argument to __builtin_annotation must be an integer}}
}
Modified: cfe/branches/tooling/test/Sema/attr-availability.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/attr-availability.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/attr-availability.c (original)
+++ cfe/branches/tooling/test/Sema/attr-availability.c Tue May 8 03:47:31 2012
@@ -24,3 +24,16 @@
NSDataWritingFileProtectionWriteOnly = 0x30000000,
NSDataWritingFileProtectionCompleteUntilUserAuthentication = 0x40000000,
};
+
+void f4(int) __attribute__((availability(ios,deprecated=3.0)));
+void f4(int) __attribute__((availability(ios,introduced=4.0))); // expected-warning {{feature cannot be deprecated in iOS version 3.0 before it was introduced in version 4.0; attribute ignored}}
+
+void f5(int) __attribute__((availability(ios,deprecated=3.0),
+ availability(ios,introduced=4.0))); // expected-warning {{feature cannot be deprecated in iOS version 3.0 before it was introduced in version 4.0; attribute ignored}}
+
+void f6(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}}
+void f6(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}}
+
+void f7(int) __attribute__((availability(ios,introduced=2.0)));
+void f7(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}}
+void f7(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}}
Modified: cfe/branches/tooling/test/Sema/attr-visibility.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/attr-visibility.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/attr-visibility.c (original)
+++ cfe/branches/tooling/test/Sema/attr-visibility.c Tue May 8 03:47:31 2012
@@ -8,4 +8,12 @@
void test3() __attribute__((visibility("protected"))); // expected-warning {{target does not support 'protected' visibility; using 'default'}}
struct __attribute__((visibility("hidden"))) test4; // expected-note {{previous attribute is here}}
+struct test4;
struct __attribute__((visibility("default"))) test4; // expected-error {{visibility does not match previous declaration}}
+
+struct test5;
+struct __attribute__((visibility("hidden"))) test5; // expected-note {{previous attribute is here}}
+struct __attribute__((visibility("default"))) test5; // expected-error {{visibility does not match previous declaration}}
+
+void test6() __attribute__((visibility("hidden"), // expected-note {{previous attribute is here}}
+ visibility("default"))); // expected-error {{visibility does not match previous declaration}}
Modified: cfe/branches/tooling/test/Sema/compare.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/compare.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/compare.c (original)
+++ cfe/branches/tooling/test/Sema/compare.c Tue May 8 03:47:31 2012
@@ -333,3 +333,10 @@
int test11(unsigned y, struct test11S *p) {
return y > (p->x >> 24); // no-warning
}
+
+typedef char one_char[1];
+typedef char two_chars[2];
+
+void test12(unsigned a) {
+ if (0 && -1 > a) { }
+}
Modified: cfe/branches/tooling/test/Sema/dllimport-dllexport.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/dllimport-dllexport.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/dllimport-dllexport.c (original)
+++ cfe/branches/tooling/test/Sema/dllimport-dllexport.c Tue May 8 03:47:31 2012
@@ -35,3 +35,6 @@
void __declspec(dllimport) foo12();
void foo12(){} // expected-warning {{'foo12' redeclared without dllimport attribute: previous dllimport ignored}}
+
+void __attribute__((dllimport)) foo13(); // expected-warning{{dllimport attribute ignored}}
+void __attribute__((dllexport)) foo13();
Modified: cfe/branches/tooling/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/format-strings.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/format-strings.c (original)
+++ cfe/branches/tooling/test/Sema/format-strings.c Tue May 8 03:47:31 2012
@@ -1,7 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs %s
+#define __need_wint_t
#include <stdarg.h>
-typedef __typeof(sizeof(int)) size_t;
+#include <stddef.h> // For wint_t and wchar_t
+
typedef struct _FILE FILE;
int fprintf(FILE *, const char *restrict, ...);
int printf(const char *restrict, ...); // expected-note{{passing argument to parameter here}}
@@ -258,7 +260,6 @@
// Unicode test cases. These are possibly specific to Mac OS X. If so, they should
// eventually be moved into a separate test.
-typedef __WCHAR_TYPE__ wchar_t;
void test_unicode_conversions(wchar_t *s) {
printf("%S", s); // no-warning
@@ -332,17 +333,18 @@
}
// PR 7981 - handle '%lc' (wint_t)
-#ifndef wint_t
-typedef int __darwin_wint_t;
-typedef __darwin_wint_t wint_t;
-#endif
void pr7981(wint_t c, wchar_t c2) {
printf("%lc", c); // no-warning
printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}}
printf("%lc", (char) 1); // no-warning
- printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *' (aka 'int *')}}
+ printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *'}}
+ // If wint_t and wchar_t are the same width and wint_t is signed where
+ // wchar_t is unsigned, an implicit conversion isn't possible.
+#if defined(__WINT_UNSIGNED__) || !defined(__WCHAR_UNSIGNED__) || \
+ __WINT_WIDTH__ > __WCHAR_WIDTH__
printf("%lc", c2); // no-warning
+#endif
}
// <rdar://problem/8269537> -Wformat-security says NULL is not a string literal
@@ -521,3 +523,10 @@
dateformat(""); // expected-warning{{format string is empty}}
dateformat(str); // no-warning (using strftime non literal is not unsafe)
}
+
+// Do not warn about unused arguments coming from system headers.
+// <rdar://problem/11317765>
+#include <format-unused-system-args.h>
+void test_unused_system_args(int x) {
+ PRINT1("%d\n", x); // no-warning{{extra argument is system header is OK}}
+}
Modified: cfe/branches/tooling/test/Sema/fpack-struct.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/fpack-struct.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/fpack-struct.c (original)
+++ cfe/branches/tooling/test/Sema/fpack-struct.c Tue May 8 03:47:31 2012
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=5 -fpack-struct 1 %s
-// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=6 -fpack-struct 2 %s
+// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=5 -fpack-struct=1 %s
+// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=6 -fpack-struct=2 %s
struct s0 {
int x;
Modified: cfe/branches/tooling/test/Sema/ms_class_layout.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/ms_class_layout.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/ms_class_layout.cpp (original)
+++ cfe/branches/tooling/test/Sema/ms_class_layout.cpp Tue May 8 03:47:31 2012
@@ -97,6 +97,48 @@
struct R {};
+class IA {
+public:
+ virtual ~IA(){}
+ virtual void ia() = 0;
+};
+
+class ICh : public virtual IA {
+public:
+ virtual ~ICh(){}
+ virtual void ia(){}
+ virtual void iCh(){}
+};
+
+struct f {
+ virtual int asd() {return -90;}
+};
+
+struct s : public virtual f {
+ virtual ~s(){}
+ int r;
+ virtual int asd() {return -9;}
+};
+
+struct sd : virtual s, virtual ICh {
+ virtual ~sd(){}
+ int q;
+ char y;
+ virtual int asd() {return -1;}
+};
+struct AV {
+ virtual void foo();
+};
+struct BV : AV {
+};
+struct CV : virtual BV {
+ CV();
+ virtual void foo();
+};
+struct DV : BV {
+};
+struct EV : CV, DV {
+};
#pragma pack(pop)
// This needs only for building layouts.
@@ -113,6 +155,8 @@
O* o;
P* p;
R* r;
+ sd *h;
+ EV *j;
return 0;
}
@@ -333,3 +377,132 @@
// CHECK-NEXT: nvsize=0, nvalign=1
//CHECK: %struct.R = type { i8 }
+
+// CHECK: 0 | struct f
+// CHECK-NEXT: 0 | (f vftable pointer)
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: 0 | struct s
+// CHECK-NEXT: 0 | (s vftable pointer)
+// CHECK-NEXT: 4 | (s vbtable pointer)
+// CHECK-NEXT: 8 | int r
+// CHECK-NEXT: 12 | (vtordisp for vbase f)
+// CHECK-NEXT: 16 | struct f (virtual base)
+// CHECK-NEXT: 16 | (f vftable pointer)
+// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: nvsize=12, nvalign=4
+
+// CHECK: 0 | class IA
+// CHECK-NEXT: 0 | (IA vftable pointer)
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: 0 | class ICh
+// CHECK-NEXT: 0 | (ICh vftable pointer)
+// CHECK-NEXT: 4 | (ICh vbtable pointer)
+// CHECK-NEXT: 8 | (vtordisp for vbase IA)
+// CHECK-NEXT: 12 | class IA (virtual base)
+// CHECK-NEXT: 12 | (IA vftable pointer)
+// CHECK-NEXT: sizeof=16, dsize=16, align=4
+// CHECK-NEXT: nvsize=8, nvalign=4
+
+// CHECK: 0 | struct sd
+// CHECK-NEXT: 0 | (sd vbtable pointer)
+// CHECK-NEXT: 4 | int q
+// CHECK-NEXT: 8 | char y
+// CHECK-NEXT: 12 | (vtordisp for vbase f)
+// CHECK-NEXT: 16 | struct f (virtual base)
+// CHECK-NEXT: 16 | (f vftable pointer)
+// CHECK-NEXT: 20 | struct s (virtual base)
+// CHECK-NEXT: 20 | (s vftable pointer)
+// CHECK-NEXT: 24 | (s vbtable pointer)
+// CHECK-NEXT: 28 | int r
+// CHECK-NEXT: 32 | (vtordisp for vbase IA)
+// CHECK-NEXT: 36 | class IA (virtual base)
+// CHECK-NEXT: 36 | (IA vftable pointer)
+// CHECK-NEXT: 40 | class ICh (virtual base)
+// CHECK-NEXT: 40 | (ICh vftable pointer)
+// CHECK-NEXT: 44 | (ICh vbtable pointer)
+// CHECK-NEXT: sizeof=48, dsize=48, align=4
+// CHECK-NEXT: nvsize=12, nvalign=4
+
+// CHECK: %struct.f = type { i32 (...)** }
+// CHECK: %struct.s = type { i32 (...)**, i32*, i32, [4 x i8], %struct.f }
+// CHECK: %class.IA = type { i32 (...)** }
+// CHECK: %class.ICh = type { i32 (...)**, i32*, [4 x i8], %class.IA }
+// CHECK: %struct.sd = type { i32*, i32, i8, [7 x i8], %struct.f, %struct.s.base, [4 x i8], %class.IA, %class.ICh.base }
+
+// CHECK: 0 | struct AV
+// CHECK-NEXT: 0 | (AV vftable pointer)
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+
+// CHECK: 0 | struct BV
+// CHECK-NEXT: 0 | struct AV (primary base)
+// CHECK-NEXT: 0 | (AV vftable pointer)
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+
+// CHECK: 0 | struct CV
+// CHECK-NEXT: 0 | (CV vbtable pointer)
+// CHECK-NEXT: 4 | (vtordisp for vbase BV)
+// CHECK-NEXT: 8 | struct BV (virtual base)
+// CHECK-NEXT: 8 | struct AV (primary base)
+// CHECK-NEXT: 8 | (AV vftable pointer)
+// CHECK-NEXT: sizeof=12, dsize=12, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: %struct.AV = type { i32 (...)** }
+// CHECK: %struct.BV = type { %struct.AV }
+// CHECK: %struct.CV = type { i32*, [4 x i8], %struct.BV }
+// CHECK: %struct.CV.base = type { i32* }
+
+// CHECK: 0 | struct DV
+// CHECK-NEXT: 0 | struct BV (primary base)
+// CHECK-NEXT: 0 | struct AV (primary base)
+// CHECK-NEXT: 0 | (AV vftable pointer)
+// CHECK-NEXT: sizeof=4, dsize=4, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+
+// CHECK: %struct.DV = type { %struct.BV }
+
+// CHECK: 0 | struct EV
+// CHECK-NEXT: 4 | struct CV (base)
+// CHECK-NEXT: 4 | (CV vbtable pointer)
+// CHECK-NEXT: 0 | struct DV (primary base)
+// CHECK-NEXT: 0 | struct BV (primary base)
+// CHECK-NEXT: 0 | struct AV (primary base)
+// CHECK-NEXT: 0 | (AV vftable pointer)
+// CHECK-NEXT: 8 | (vtordisp for vbase BV)
+// CHECK-NEXT: 12 | struct BV (virtual base)
+// CHECK-NEXT: 12 | struct AV (primary base)
+// CHECK-NEXT: 12 | (AV vftable pointer)
+// CHECK-NEXT: sizeof=16, dsize=16, align=4
+// CHECK-NEXT: nvsize=8, nvalign=4
+
+// CHECK: %struct.EV = type { %struct.DV, %struct.CV.base, [4 x i8], %struct.BV }
+// CHECK: %struct.EV.base = type { %struct.DV, %struct.CV.base }
+
+// Overriding a method means that all the vbases containing that
+// method need a vtordisp.
+namespace test1 {
+ struct A { virtual void foo(); };
+ struct B : A {};
+ struct C : virtual A, virtual B { C(); virtual void foo(); };
+ void test() { C *c; }
+
+// CHECK: 0 | struct test1::C
+// CHECK-NEXT: 0 | (C vbtable pointer)
+// CHECK-NEXT: 4 | (vtordisp for vbase A)
+// CHECK-NEXT: 8 | struct test1::A (virtual base)
+// CHECK-NEXT: 8 | (A vftable pointer)
+// CHECK-NEXT: 12 | (vtordisp for vbase B)
+// CHECK-NEXT: 16 | struct test1::B (virtual base)
+// CHECK-NEXT: 16 | struct test1::A (primary base)
+// CHECK-NEXT: 16 | (A vftable pointer)
+// CHECK-NEXT: sizeof=20, dsize=20, align=4
+// CHECK-NEXT: nvsize=4, nvalign=4
+}
Modified: cfe/branches/tooling/test/Sema/uninit-variables.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/uninit-variables.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/uninit-variables.c (original)
+++ cfe/branches/tooling/test/Sema/uninit-variables.c Tue May 8 03:47:31 2012
@@ -424,3 +424,13 @@
for (; i < 10000; ++i) // expected-warning {{variable 'i' is uninitialized when used here}}
P[i] = 0.0f;
}
+
+// Test that fixits are not emitted inside macros.
+#define UNINIT(T, x, y) T x; T y = x;
+#define ASSIGN(T, x, y) T y = x;
+void test54() {
+ UNINIT(int, a, b); // expected-warning {{variable 'a' is uninitialized when used here}} \
+ // expected-note {{variable 'a' is declared here}}
+ int c; // expected-note {{initialize the variable 'c' to silence this warning}}
+ ASSIGN(int, c, d); // expected-warning {{variable 'c' is uninitialized when used here}}
+}
Modified: cfe/branches/tooling/test/Sema/vector-ops.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/Sema/vector-ops.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/Sema/vector-ops.c (original)
+++ cfe/branches/tooling/test/Sema/vector-ops.c Tue May 8 03:47:31 2012
@@ -13,7 +13,7 @@
(void)(~v2fa); // expected-error{{invalid argument type 'v2f' to unary}}
// Comparison operators
- v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' from 'int __attribute__((ext_vector_type(2)))'}}
+ v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' from 'int __attribute__((ext_vector_type(2)))'}}
v2sa = (v2ua==v2sa);
// Arrays
Modified: cfe/branches/tooling/test/SemaCXX/abstract.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/abstract.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/abstract.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/abstract.cpp Tue May 8 03:47:31 2012
@@ -259,3 +259,17 @@
};
};
}
+
+namespace pr12658 {
+ class C {
+ public:
+ C(int v){}
+ virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f' in 'C'}}
+ };
+
+ void foo( C& c ) {}
+
+ void bar( void ) {
+ foo(C(99)); // expected-error {{allocating an object of abstract class type 'pr12658::C'}}
+ }
+}
Modified: cfe/branches/tooling/test/SemaCXX/constant-expression-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/constant-expression-cxx11.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/constant-expression-cxx11.cpp Tue May 8 03:47:31 2012
@@ -1248,3 +1248,13 @@
}
constexpr auto v2 = g(4);
}
+
+// PR12626, redux
+namespace InvalidClasses {
+ void test0() {
+ struct X; // expected-note {{forward declaration}}
+ struct Y { bool b; X x; }; // expected-error {{field has incomplete type}}
+ Y y;
+ auto& b = y.b;
+ }
+}
Modified: cfe/branches/tooling/test/SemaCXX/conversion-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/conversion-function.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/conversion-function.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/conversion-function.cpp Tue May 8 03:47:31 2012
@@ -392,3 +392,14 @@
A& a4 = (A&)c;
}
}
+
+namespace PR12712 {
+ struct A {};
+ struct B {
+ operator A();
+ operator A() const;
+ };
+ struct C : B {};
+
+ A f(const C c) { return c; }
+}
Modified: cfe/branches/tooling/test/SemaCXX/conversion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/conversion.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/conversion.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/conversion.cpp Tue May 8 03:47:31 2012
@@ -81,3 +81,26 @@
#define FINIT int a3 = NULL;
FINIT // expected-warning {{implicit conversion of NULL constant to 'int'}}
}
+
+namespace test4 {
+ // FIXME: We should warn for non-dependent args (only when the param type is also non-dependent) only once
+ // not once for the template + once for every instantiation
+ template<typename T>
+ void tmpl(char c = NULL, // expected-warning 4 {{implicit conversion of NULL constant to 'char'}}
+ T a = NULL, // expected-warning {{implicit conversion of NULL constant to 'char'}} \
+ expected-warning 2 {{implicit conversion of NULL constant to 'int'}}
+ T b = 1024) { // expected-warning {{implicit conversion from 'int' to 'char' changes value from 1024 to 0}}
+ }
+
+ template<typename T>
+ void tmpl2(T t = NULL) {
+ }
+
+ void func() {
+ tmpl<char>(); // expected-note 2 {{in instantiation of default function argument expression for 'tmpl<char>' required here}}
+ tmpl<int>(); // expected-note 2 {{in instantiation of default function argument expression for 'tmpl<int>' required here}}
+ // FIXME: We should warn only once for each template instantiation - not once for each call
+ tmpl<int>(); // expected-note 2 {{in instantiation of default function argument expression for 'tmpl<int>' required here}}
+ tmpl2<int*>();
+ }
+}
Modified: cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/cxx98-compat.cpp Tue May 8 03:47:31 2012
@@ -138,12 +138,16 @@
void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}}
static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}}
+// FIXME: Reintroduce this test if support for inheriting constructors is
+// implemented.
+#if 0
struct InhCtorBase {
InhCtorBase(int);
};
struct InhCtorDerived : InhCtorBase {
- using InhCtorBase::InhCtorBase; // expected-warning {{inherited constructors are incompatible with C++98}}
+ using InhCtorBase::InhCtorBase; // xpected-warning {{inheriting constructors are incompatible with C++98}}
};
+#endif
struct FriendMember {
static void MemberFn();
@@ -324,16 +328,6 @@
S<void(&)(), f> s2; // expected-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}}
}
-namespace ThisInExceptionSpec {
- template<int> struct T {};
- struct S {
- int n;
- void f() throw (T<sizeof(n)>); // expected-warning {{use of 'this' outside a non-static member function is incompatible with C++98}}
- void g() throw (T<sizeof(S::n)>); // expected-warning {{use of 'this' outside a non-static member function is incompatible with C++98}}
- void h() throw (T<sizeof(this)>); // expected-warning {{use of 'this' outside a non-static member function is incompatible with C++98}}
- };
-}
-
namespace NullPointerTemplateArg {
struct A {};
template<int*> struct X {};
Modified: cfe/branches/tooling/test/SemaCXX/decl-expr-ambiguity.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/decl-expr-ambiguity.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/decl-expr-ambiguity.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/decl-expr-ambiguity.cpp Tue May 8 03:47:31 2012
@@ -70,3 +70,23 @@
fn(1); // expected-error {{no matching function}}
fn(g); // OK
}
+
+namespace PR11874 {
+void foo(); // expected-note 3 {{class 'foo' is hidden by a non-type declaration of 'foo' here}}
+class foo {};
+class bar {
+ bar() {
+ const foo* f1 = 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
+ foo* f2 = 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
+ foo f3; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}}
+ }
+};
+
+int baz; // expected-note 2 {{class 'baz' is hidden by a non-type declaration of 'baz' here}}
+class baz {};
+void fizbin() {
+ const baz* b1 = 0; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}}
+ baz* b2; // expected-error {{use of undeclared identifier 'b2'}}
+ baz b3; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}}
+}
+}
Modified: cfe/branches/tooling/test/SemaCXX/dependent-noexcept-unevaluated.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/dependent-noexcept-unevaluated.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/dependent-noexcept-unevaluated.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/dependent-noexcept-unevaluated.cpp Tue May 8 03:47:31 2012
@@ -23,7 +23,7 @@
{
T data[N];
- void swap(array& a) noexcept(noexcept(::swap(declval<T&>(), declval<T&>())));
+ void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>())));
};
struct DefaultOnly
@@ -38,4 +38,3 @@
{
array<DefaultOnly, 1> a, b;
}
-
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=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/implicit-exception-spec.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/implicit-exception-spec.cpp Tue May 8 03:47:31 2012
@@ -40,9 +40,12 @@
}
namespace ExceptionSpecification {
- struct Nested {
+ // A type is permitted to be used in a dynamic exception specification when it
+ // is still being defined, but isn't complete within such an exception
+ // specification.
+ struct Nested { // expected-note {{not complete}}
struct T {
- T() noexcept(!noexcept(Nested())); // expected-error{{exception specification is not available until end of class definition}}
+ T() noexcept(!noexcept(Nested())); // expected-error{{incomplete type}}
} t;
};
}
Modified: cfe/branches/tooling/test/SemaCXX/invalid-member-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/invalid-member-expr.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/invalid-member-expr.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/invalid-member-expr.cpp Tue May 8 03:47:31 2012
@@ -37,3 +37,34 @@
string::iterator i = s.foo(); // expected-error {{no member named 'foo'}}
}
}
+
+
+// Make sure we don't crash.
+namespace rdar11293995 {
+
+struct Length {
+ explicit Length(PassRefPtr<CalculationValue>); // expected-error {{unknown type name}} \
+ expected-error {{expected ')'}} \
+ expected-note {{to match this '('}}
+};
+
+struct LengthSize {
+ Length m_width;
+ Length m_height;
+};
+
+enum EFillSizeType { Contain, Cover, SizeLength, SizeNone };
+
+struct FillSize {
+ EFillSizeType type;
+ LengthSize size;
+};
+
+class FillLayer {
+public:
+ void setSize(FillSize f) { m_sizeType = f.type;}
+private:
+ unsigned m_sizeType : 2;
+};
+
+}
Modified: cfe/branches/tooling/test/SemaCXX/type-traits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/type-traits.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/type-traits.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/type-traits.cpp Tue May 8 03:47:31 2012
@@ -131,25 +131,25 @@
{ int arr[T(__is_pod(HasAnonymousUnion))]; }
{ int arr[T(__is_pod(Vector))]; }
{ int arr[T(__is_pod(VectorExt))]; }
+ { int arr[T(__is_pod(Derives))]; }
+ { int arr[T(__is_pod(DerivesAr))]; }
+ { int arr[T(__is_pod(DerivesArNB))]; }
+ { int arr[T(__is_pod(DerivesEmpty))]; }
+ { int arr[T(__is_pod(HasPriv))]; }
+ { int arr[T(__is_pod(HasProt))]; }
+ { int arr[T(__is_pod(DerivesHasPriv))]; }
+ { int arr[T(__is_pod(DerivesHasProt))]; }
- { int arr[F(__is_pod(Derives))]; }
- { int arr[F(__is_pod(DerivesAr))]; }
- { int arr[F(__is_pod(DerivesArNB))]; }
- { int arr[F(__is_pod(DerivesEmpty))]; }
{ int arr[F(__is_pod(HasCons))]; }
{ int arr[F(__is_pod(HasCopyAssign))]; }
{ int arr[F(__is_pod(HasMoveAssign))]; }
{ int arr[F(__is_pod(HasDest))]; }
- { int arr[F(__is_pod(HasPriv))]; }
- { int arr[F(__is_pod(HasProt))]; }
{ int arr[F(__is_pod(HasRef))]; }
{ int arr[F(__is_pod(HasVirt))]; }
{ int arr[F(__is_pod(DerivesHasCons))]; }
{ int arr[F(__is_pod(DerivesHasCopyAssign))]; }
{ int arr[F(__is_pod(DerivesHasMoveAssign))]; }
{ int arr[F(__is_pod(DerivesHasDest))]; }
- { int arr[F(__is_pod(DerivesHasPriv))]; }
- { int arr[F(__is_pod(DerivesHasProt))]; }
{ int arr[F(__is_pod(DerivesHasRef))]; }
{ int arr[F(__is_pod(DerivesHasVirt))]; }
{ int arr[F(__is_pod(NonPOD))]; }
@@ -1223,10 +1223,10 @@
{ int arr[T(__has_trivial_copy(const Int))]; }
{ int arr[T(__has_trivial_copy(AllDefaulted))]; }
{ int arr[T(__has_trivial_copy(AllDeleted))]; }
+ { int arr[T(__has_trivial_copy(DerivesAr))]; }
{ int arr[F(__has_trivial_copy(HasCopy))]; }
{ int arr[F(__has_trivial_copy(HasTemplateCons))]; }
- { int arr[F(__has_trivial_copy(DerivesAr))]; }
{ int arr[F(__has_trivial_copy(VirtAr))]; }
{ int arr[F(__has_trivial_copy(void))]; }
{ int arr[F(__has_trivial_copy(cvoid))]; }
@@ -1250,13 +1250,13 @@
{ int arr[T(__has_trivial_assign(HasMoveAssign))]; }
{ int arr[T(__has_trivial_assign(AllDefaulted))]; }
{ int arr[T(__has_trivial_assign(AllDeleted))]; }
+ { int arr[T(__has_trivial_assign(DerivesAr))]; }
{ int arr[F(__has_trivial_assign(IntRef))]; }
{ int arr[F(__has_trivial_assign(HasCopyAssign))]; }
{ int arr[F(__has_trivial_assign(const Int))]; }
{ int arr[F(__has_trivial_assign(ConstIntAr))]; }
{ int arr[F(__has_trivial_assign(ConstIntArAr))]; }
- { int arr[F(__has_trivial_assign(DerivesAr))]; }
{ int arr[F(__has_trivial_assign(VirtAr))]; }
{ int arr[F(__has_trivial_assign(void))]; }
{ int arr[F(__has_trivial_assign(cvoid))]; }
@@ -1338,6 +1338,7 @@
{ int arr[T(__has_nothrow_assign(HasVirtDest))]; }
{ int arr[T(__has_nothrow_assign(AllPrivate))]; }
{ int arr[T(__has_nothrow_assign(UsingAssign))]; }
+ { int arr[T(__has_nothrow_assign(DerivesAr))]; }
{ int arr[F(__has_nothrow_assign(IntRef))]; }
{ int arr[F(__has_nothrow_assign(HasCopyAssign))]; }
@@ -1345,7 +1346,6 @@
{ int arr[F(__has_nothrow_assign(const Int))]; }
{ int arr[F(__has_nothrow_assign(ConstIntAr))]; }
{ int arr[F(__has_nothrow_assign(ConstIntArAr))]; }
- { int arr[F(__has_nothrow_assign(DerivesAr))]; }
{ int arr[F(__has_nothrow_assign(VirtAr))]; }
{ int arr[F(__has_nothrow_assign(void))]; }
{ int arr[F(__has_nothrow_assign(cvoid))]; }
@@ -1375,10 +1375,10 @@
{ int arr[T(__has_nothrow_copy(HasVirtDest))]; }
{ int arr[T(__has_nothrow_copy(HasTemplateCons))]; }
{ int arr[T(__has_nothrow_copy(AllPrivate))]; }
+ { int arr[T(__has_nothrow_copy(DerivesAr))]; }
{ int arr[F(__has_nothrow_copy(HasCopy))]; }
{ int arr[F(__has_nothrow_copy(HasMultipleCopy))]; }
- { int arr[F(__has_nothrow_copy(DerivesAr))]; }
{ int arr[F(__has_nothrow_copy(VirtAr))]; }
{ int arr[F(__has_nothrow_copy(void))]; }
{ int arr[F(__has_nothrow_copy(cvoid))]; }
Modified: cfe/branches/tooling/test/SemaCXX/virtuals.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaCXX/virtuals.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/virtuals.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/virtuals.cpp Tue May 8 03:47:31 2012
@@ -30,7 +30,7 @@
// expected-error{{return type 'A' is an abstract class}}
{
A a; // expected-error{{variable type 'A' is an abstract class}}
- (void)static_cast<A>(0);
+ (void)static_cast<A>(0); // expected-error{{allocating an object of abstract class type 'A'}}
try {
} catch(A) { // expected-error{{variable type 'A' is an abstract class}}
}
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=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-thread-safety-analysis.cpp Tue May 8 03:47:31 2012
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 -Wc++98-compat %s
#define LOCKABLE __attribute__ ((lockable))
#define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
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=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp (original)
+++ cfe/branches/tooling/test/SemaCXX/warn-thread-safety-parsing.cpp Tue May 8 03:47:31 2012
@@ -970,7 +970,7 @@
int lr_function_bad_1() LOCK_RETURNED(1); // \
// expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
int lr_function_bad_2() LOCK_RETURNED("mu"); // \
- // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{ignoring 'lock_returned' attribute because its argument is invalid}}
int lr_function_bad_3() LOCK_RETURNED(muDoublePointer); // \
// expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
int lr_function_bad_4() LOCK_RETURNED(umu); // \
@@ -1319,6 +1319,8 @@
Mutex mu_;
};
+} // end namespace TestMultiDecl
+
namespace NestedClassLateDecl {
@@ -1350,6 +1352,8 @@
class Graph {
public:
Mutex mu_;
+
+ static Mutex* get_static_mu() LOCK_RETURNED(&Graph::mu_);
};
class Node {
@@ -1366,8 +1370,6 @@
template<class T>
class smart_ptr {
public:
- smart_ptr(T* p) : ptr_(p) { };
-
T* operator->() { return ptr_; }
T& operator*() { return ptr_; }
@@ -1376,15 +1378,55 @@
};
+Mutex gmu;
+smart_ptr<int> gdat PT_GUARDED_BY(gmu);
+
+
class MyClass {
public:
Mutex mu_;
+ smart_ptr<Mutex> smu_;
+
smart_ptr<int> a PT_GUARDED_BY(mu_);
+ int b GUARDED_BY(smu_);
+};
+
+}
+
+
+namespace InheritanceTest {
+
+class LOCKABLE Base {
+ public:
+ void lock() EXCLUSIVE_LOCK_FUNCTION();
+ void unlock() UNLOCK_FUNCTION();
+};
+
+class Base2 { };
+
+class Derived1 : public Base { };
+
+class Derived2 : public Base2, public Derived1 { };
+
+class Derived3 : public Base2 { };
+
+class Foo {
+ Derived1 mu1_;
+ Derived2 mu2_;
+ Derived3 mu3_;
+ int a GUARDED_BY(mu1_);
+ int b GUARDED_BY(mu2_);
+ int c GUARDED_BY(mu3_); // \
+ // expected-warning {{'guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute; type here is 'class InheritanceTest::Derived3'}}
+
+ void foo() EXCLUSIVE_LOCKS_REQUIRED(mu1_, mu2_) {
+ a = 0;
+ b = 0;
+ }
};
}
-} // end namespace TestMultiDecl
Propchange: cfe/branches/tooling/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 8 03:47:31 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-155648
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,146581-156373
Modified: cfe/branches/tooling/test/SemaObjC/boxing-illegal-types.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/boxing-illegal-types.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/boxing-illegal-types.m (original)
+++ cfe/branches/tooling/test/SemaObjC/boxing-illegal-types.m Tue May 8 03:47:31 2012
@@ -6,12 +6,12 @@
void testStruct() {
point p = { 0, 0, 0 };
- id boxed = @(p); // expected-error {{Illegal type 'point' used in a boxed expression}}
+ id boxed = @(p); // expected-error {{illegal type 'point' used in a boxed expression}}
}
void testPointers() {
void *null = 0;
- id boxed_null = @(null); // expected-error {{Illegal type 'void *' used in a boxed expression}}
+ id boxed_null = @(null); // expected-error {{illegal type 'void *' used in a boxed expression}}
int numbers[] = { 0, 1, 2 };
- id boxed_numbers = @(numbers); // expected-error {{Illegal type 'int *' used in a boxed expression}}
+ id boxed_numbers = @(numbers); // expected-error {{illegal type 'int *' used in a boxed expression}}
}
Modified: cfe/branches/tooling/test/SemaObjC/default-synthesize-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/default-synthesize-1.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/default-synthesize-1.m (original)
+++ cfe/branches/tooling/test/SemaObjC/default-synthesize-1.m Tue May 8 03:47:31 2012
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -Wobjc-missing-property-synthesis -verify -Wno-objc-root-class %s
+// rdar://11295716
@interface NSObject
- (void) release;
@@ -7,21 +8,21 @@
@class NSString;
@interface SynthItAll : NSObject
- at property int howMany;
- at property (retain) NSString* what;
+ at property int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
+ at property (retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
@end
- at implementation SynthItAll
+ at implementation SynthItAll // expected-note 2 {{detected while default synthesizing properties in class implementation}}
//@synthesize howMany, what;
@end
@interface SynthSetter : NSObject
- at property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
- at property (nonatomic, retain) NSString* what;
+ at property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
+ at property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
@end
- at implementation SynthSetter
+ at implementation SynthSetter // expected-note 2 {{detected while default synthesizing properties in class implementation}}
//@synthesize howMany, what;
- (int) howMany {
@@ -37,11 +38,11 @@
@interface SynthGetter : NSObject
- at property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
- at property (nonatomic, retain) NSString* what;
+ at property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
+ at property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
@end
- at implementation SynthGetter
+ at implementation SynthGetter // expected-note 2 {{detected while default synthesizing properties in class implementation}}
//@synthesize howMany, what;
// - (int) howMany
@@ -114,3 +115,12 @@
}
@end
+ at interface rdar11333367
+ at property enum A x; // expected-note {{forward declaration of 'enum A'}} expected-note {{property declared here}}
+ at property struct B y; // expected-note {{forward declaration of 'struct B'}} expected-note {{property declared here}} \
+ // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
+ at end
+ at implementation rdar11333367 // expected-error {{cannot synthesize property 'y' with incomplete type 'struct B'}} \
+ // expected-note {{detected while default synthesizing properties in class implementation}}
+ at synthesize x; // expected-error {{cannot synthesize property 'x' with incomplete type 'enum A'}}
+ at end
Modified: cfe/branches/tooling/test/SemaObjC/format-strings-objc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/format-strings-objc.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/format-strings-objc.m (original)
+++ cfe/branches/tooling/test/SemaObjC/format-strings-objc.m Tue May 8 03:47:31 2012
@@ -111,11 +111,20 @@
}
// Do not emit warnings when using NSLocalizedString
-extern NSString *GetLocalizedString(NSString *str);
-#define NSLocalizedString(key) GetLocalizedString(key)
+#include "format-strings-system.h"
+
+// Test it inhibits diag only for macros in system headers
+#define MyNSLocalizedString(key) GetLocalizedString(key)
+#define MyNSAssert(fmt, arg) NSLog(fmt, arg, 0, 0)
void check_NSLocalizedString() {
[Foo fooWithFormat:NSLocalizedString(@"format"), @"arg"]; // no-warning
+ [Foo fooWithFormat:MyNSLocalizedString(@"format"), @"arg"]; // expected-warning {{format string is not a string literal}}}
+}
+
+void check_NSAssert() {
+ NSAssert(@"Hello %@", @"World"); // no-warning
+ MyNSAssert(@"Hello %@", @"World"); // expected-warning {{data argument not used by format string}}
}
typedef __WCHAR_TYPE__ wchar_t;
Modified: cfe/branches/tooling/test/SemaObjC/property-10.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/property-10.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/property-10.m (original)
+++ cfe/branches/tooling/test/SemaObjC/property-10.m Tue May 8 03:47:31 2012
@@ -24,7 +24,7 @@
@property(unsafe_unretained, copy, retain) id p4_3; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'unsafe_unretained' and 'retain' are mutually exclusive}}
@property(unsafe_unretained, copy, strong) id s4_3; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'unsafe_unretained' and 'strong' are mutually exclusive}}
- at property id p4; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-gc object}}
+ at property id p4; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-GC object}}
@property(nonatomic,copy) int (^includeMailboxCondition)();
@property(nonatomic,copy) int (*includeMailboxCondition2)(); // expected-error {{property with 'copy' attribute must be of object type}}
Modified: cfe/branches/tooling/test/SemaObjC/property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjC/property.m?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjC/property.m (original)
+++ cfe/branches/tooling/test/SemaObjC/property.m Tue May 8 03:47:31 2012
@@ -6,7 +6,7 @@
int name;
}
@property int d1;
- at property id prop_id; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-gc object}}
+ at property id prop_id; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-GC object}}
@property int name;
@end
Modified: cfe/branches/tooling/test/SemaObjCXX/property-synthesis-error.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaObjCXX/property-synthesis-error.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaObjCXX/property-synthesis-error.mm (original)
+++ cfe/branches/tooling/test/SemaObjCXX/property-synthesis-error.mm Tue May 8 03:47:31 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -fobjc-default-synthesize-properties %s
// rdar: //8550657
@interface NSArray @end
@@ -72,3 +72,14 @@
@synthesize tcppObject = _tcppObject;
@end
+
+struct IncompleteStruct; // expected-note 2 {{forward declaration of 'IncompleteStruct'}}
+struct ConvertToIncomplete { operator IncompleteStruct&(); };
+ at interface SynthIncompleteRef
+ at property (readonly, nonatomic) IncompleteStruct& x; // expected-note {{property declared here}}
+ at property (readonly, nonatomic) IncompleteStruct& y; // expected-note {{property declared here}}
+ at end
+
+ at implementation SynthIncompleteRef // expected-error {{cannot synthesize property 'x' with incomplete type 'IncompleteStruct'}}
+ at synthesize y; // expected-error {{cannot synthesize property 'y' with incomplete type 'IncompleteStruct'}}
+ at end
Modified: cfe/branches/tooling/test/SemaTemplate/default-expr-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/default-expr-arguments.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/default-expr-arguments.cpp (original)
+++ cfe/branches/tooling/test/SemaTemplate/default-expr-arguments.cpp Tue May 8 03:47:31 2012
@@ -292,3 +292,14 @@
f();
}
}
+
+namespace PR12581 {
+ const int a = 0;
+ template < typename > struct A;
+ template < typename MatrixType, int =
+ A < MatrixType >::Flags ? : A < MatrixType >::Flags & a > class B;
+ void
+ fn1 ()
+ {
+ }
+}
Modified: cfe/branches/tooling/test/SemaTemplate/instantiate-objc-1.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/instantiate-objc-1.mm?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/instantiate-objc-1.mm (original)
+++ cfe/branches/tooling/test/SemaTemplate/instantiate-objc-1.mm Tue May 8 03:47:31 2012
@@ -50,8 +50,8 @@
// @() boxing expressions.
template <typename T> struct BoxingTest {
static id box(T value) {
- return @(value); // expected-error {{Illegal type 'int *' used in a boxed expression}} \
- // expected-error {{Illegal type 'long double' used in a boxed expression}}
+ return @(value); // expected-error {{illegal type 'int *' used in a boxed expression}} \
+ // expected-error {{illegal type 'long double' used in a boxed expression}}
}
};
Modified: cfe/branches/tooling/test/SemaTemplate/overload-candidates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/test/SemaTemplate/overload-candidates.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/test/SemaTemplate/overload-candidates.cpp (original)
+++ cfe/branches/tooling/test/SemaTemplate/overload-candidates.cpp Tue May 8 03:47:31 2012
@@ -24,7 +24,9 @@
}
template<typename T>
- typename T::type get_type(const T&); // expected-note{{candidate template ignored: substitution failure [with T = int *]}}
+ typename T::type get_type(const T&); // expected-note{{candidate template ignored: substitution failure [with T = int *]: type 'int *' cannot be used prior to '::'}}
+template<typename T>
+ void get_type(T *, int[(int)sizeof(T) - 9] = 0); // expected-note{{candidate template ignored: substitution failure [with T = int]: array size is negative}}
void test_get_type(int *ptr) {
(void)get_type(ptr); // expected-error{{no matching function for call to 'get_type'}}
Modified: cfe/branches/tooling/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/c-index-test/c-index-test.c?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/c-index-test/c-index-test.c (original)
+++ cfe/branches/tooling/tools/c-index-test/c-index-test.c Tue May 8 03:47:31 2012
@@ -180,6 +180,20 @@
int want_display_name = 0;
+static void printVersion(const char *Prefix, CXVersion Version) {
+ if (Version.Major < 0)
+ return;
+ printf("%s%d", Prefix, Version.Major);
+
+ if (Version.Minor < 0)
+ return;
+ printf(".%d", Version.Minor);
+
+ if (Version.Subminor < 0)
+ return;
+ printf(".%d", Version.Subminor);
+}
+
static void PrintCursor(CXCursor Cursor) {
CXTranslationUnit TU = clang_Cursor_getTranslationUnit(Cursor);
if (clang_isInvalid(Cursor.kind)) {
@@ -197,7 +211,14 @@
unsigned RefNameRangeNr;
CXSourceRange CursorExtent;
CXSourceRange RefNameRange;
-
+ int AlwaysUnavailable;
+ int AlwaysDeprecated;
+ CXString UnavailableMessage;
+ CXString DeprecatedMessage;
+ CXPlatformAvailability PlatformAvailability[2];
+ int NumPlatformAvailability;
+ int I;
+
ks = clang_getCursorKindSpelling(Cursor.kind);
string = want_display_name? clang_getCursorDisplayName(Cursor)
: clang_getCursorSpelling(Cursor);
@@ -249,6 +270,47 @@
break;
}
+ NumPlatformAvailability
+ = clang_getCursorPlatformAvailability(Cursor,
+ &AlwaysDeprecated,
+ &DeprecatedMessage,
+ &AlwaysUnavailable,
+ &UnavailableMessage,
+ PlatformAvailability, 2);
+ if (AlwaysUnavailable) {
+ printf(" (always unavailable: \"%s\")",
+ clang_getCString(UnavailableMessage));
+ } else if (AlwaysDeprecated) {
+ printf(" (always deprecated: \"%s\")",
+ clang_getCString(DeprecatedMessage));
+ } else {
+ for (I = 0; I != NumPlatformAvailability; ++I) {
+ if (I >= 2)
+ break;
+
+ printf(" (%s", clang_getCString(PlatformAvailability[I].Platform));
+ if (PlatformAvailability[I].Unavailable)
+ printf(", unavailable");
+ else {
+ printVersion(", introduced=", PlatformAvailability[I].Introduced);
+ printVersion(", deprecated=", PlatformAvailability[I].Deprecated);
+ printVersion(", obsoleted=", PlatformAvailability[I].Obsoleted);
+ }
+ if (clang_getCString(PlatformAvailability[I].Message)[0])
+ printf(", message=\"%s\"",
+ clang_getCString(PlatformAvailability[I].Message));
+ printf(")");
+ }
+ }
+ for (I = 0; I != NumPlatformAvailability; ++I) {
+ if (I >= 2)
+ break;
+ clang_disposeCXPlatformAvailability(PlatformAvailability + I);
+ }
+
+ clang_disposeString(DeprecatedMessage);
+ clang_disposeString(UnavailableMessage);
+
if (clang_CXXMethod_isStatic(Cursor))
printf(" (static)");
if (clang_CXXMethod_isVirtual(Cursor))
Modified: cfe/branches/tooling/tools/driver/cc1_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/driver/cc1_main.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/driver/cc1_main.cpp (original)
+++ cfe/branches/tooling/tools/driver/cc1_main.cpp Tue May 8 03:47:31 2012
@@ -15,7 +15,7 @@
#include "clang/Driver/Arg.h"
#include "clang/Driver/ArgList.h"
-#include "clang/Driver/CC1Options.h"
+#include "clang/Driver/Options.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/OptTable.h"
#include "clang/Frontend/CompilerInstance.h"
@@ -58,7 +58,7 @@
llvm::errs() << "\n";
// Parse the arguments.
- OptTable *Opts = createCC1OptTable();
+ OptTable *Opts = createDriverOptTable();
unsigned MissingArgIndex, MissingArgCount;
InputArgList *Args = Opts->ParseArgs(ArgBegin, ArgEnd,
MissingArgIndex, MissingArgCount);
Modified: cfe/branches/tooling/tools/driver/driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/driver/driver.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/driver/driver.cpp (original)
+++ cfe/branches/tooling/tools/driver/driver.cpp Tue May 8 03:47:31 2012
@@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Driver/ArgList.h"
-#include "clang/Driver/CC1Options.h"
+#include "clang/Driver/Options.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Option.h"
@@ -378,7 +378,7 @@
DiagnosticOptions DiagOpts;
{
// Note that ParseDiagnosticArgs() uses the cc1 option table.
- OwningPtr<OptTable> CC1Opts(createCC1OptTable());
+ OwningPtr<OptTable> CC1Opts(createDriverOptTable());
unsigned MissingArgIndex, MissingArgCount;
OwningPtr<InputArgList> Args(CC1Opts->ParseArgs(argv.begin()+1, argv.end(),
MissingArgIndex, MissingArgCount));
Modified: cfe/branches/tooling/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CIndex.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CIndex.cpp Tue May 8 03:47:31 2012
@@ -61,6 +61,7 @@
D->TUData = TU;
D->StringPool = createCXStringPool();
D->Diagnostics = 0;
+ D->OverridenCursorsPool = createOverridenCXCursorsPool();
return D;
}
@@ -2734,6 +2735,7 @@
delete static_cast<ASTUnit *>(CTUnit->TUData);
disposeCXStringPool(CTUnit->StringPool);
delete static_cast<CXDiagnosticSetImpl *>(CTUnit->Diagnostics);
+ disposeOverridenCXCursorsPool(CTUnit->OverridenCursorsPool);
delete CTUnit;
}
}
@@ -2829,8 +2831,8 @@
}
CXCursor clang_getTranslationUnitCursor(CXTranslationUnit TU) {
- CXCursor Result = { CXCursor_TranslationUnit, 0, { 0, 0, TU } };
- return Result;
+ ASTUnit *CXXUnit = static_cast<ASTUnit*>(TU->TUData);
+ return MakeCXCursor(CXXUnit->getASTContext().getTranslationUnitDecl(), TU);
}
} // end: extern "C"
@@ -5487,6 +5489,90 @@
return CXAvailability_Available;
}
+static CXVersion convertVersion(VersionTuple In) {
+ CXVersion Out = { -1, -1, -1 };
+ if (In.empty())
+ return Out;
+
+ Out.Major = In.getMajor();
+
+ if (llvm::Optional<unsigned> Minor = In.getMinor())
+ Out.Minor = *Minor;
+ else
+ return Out;
+
+ if (llvm::Optional<unsigned> Subminor = In.getSubminor())
+ Out.Subminor = *Subminor;
+
+ return Out;
+}
+
+int clang_getCursorPlatformAvailability(CXCursor cursor,
+ int *always_deprecated,
+ CXString *deprecated_message,
+ int *always_unavailable,
+ CXString *unavailable_message,
+ CXPlatformAvailability *availability,
+ int availability_size) {
+ if (always_deprecated)
+ *always_deprecated = 0;
+ if (deprecated_message)
+ *deprecated_message = cxstring::createCXString("", /*DupString=*/false);
+ if (always_unavailable)
+ *always_unavailable = 0;
+ if (unavailable_message)
+ *unavailable_message = cxstring::createCXString("", /*DupString=*/false);
+
+ if (!clang_isDeclaration(cursor.kind))
+ return 0;
+
+ Decl *D = cxcursor::getCursorDecl(cursor);
+ if (!D)
+ return 0;
+
+ int N = 0;
+ for (Decl::attr_iterator A = D->attr_begin(), AEnd = D->attr_end(); A != AEnd;
+ ++A) {
+ if (DeprecatedAttr *Deprecated = dyn_cast<DeprecatedAttr>(*A)) {
+ if (always_deprecated)
+ *always_deprecated = 1;
+ if (deprecated_message)
+ *deprecated_message = cxstring::createCXString(Deprecated->getMessage());
+ continue;
+ }
+
+ if (UnavailableAttr *Unavailable = dyn_cast<UnavailableAttr>(*A)) {
+ if (always_unavailable)
+ *always_unavailable = 1;
+ if (unavailable_message) {
+ *unavailable_message
+ = cxstring::createCXString(Unavailable->getMessage());
+ }
+ continue;
+ }
+
+ if (AvailabilityAttr *Avail = dyn_cast<AvailabilityAttr>(*A)) {
+ if (N < availability_size) {
+ availability[N].Platform
+ = cxstring::createCXString(Avail->getPlatform()->getName());
+ availability[N].Introduced = convertVersion(Avail->getIntroduced());
+ availability[N].Deprecated = convertVersion(Avail->getDeprecated());
+ availability[N].Obsoleted = convertVersion(Avail->getObsoleted());
+ availability[N].Unavailable = Avail->getUnavailable();
+ availability[N].Message = cxstring::createCXString(Avail->getMessage());
+ }
+ ++N;
+ }
+ }
+
+ return N;
+}
+
+void clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability) {
+ clang_disposeString(availability->Platform);
+ clang_disposeString(availability->Message);
+}
+
CXLanguageKind clang_getCursorLanguage(CXCursor cursor) {
if (clang_isDeclaration(cursor.kind))
return getDeclLanguage(cxcursor::getCursorDecl(cursor));
@@ -5549,34 +5635,6 @@
return clang_getNullCursor();
}
-void clang_getOverriddenCursors(CXCursor cursor,
- CXCursor **overridden,
- unsigned *num_overridden) {
- if (overridden)
- *overridden = 0;
- if (num_overridden)
- *num_overridden = 0;
- if (!overridden || !num_overridden)
- return;
- if (!clang_isDeclaration(cursor.kind))
- return;
-
- SmallVector<CXCursor, 8> Overridden;
- cxcursor::getOverriddenCursors(cursor, Overridden);
-
- // Don't allocate memory if we have no overriden cursors.
- if (Overridden.size() == 0)
- return;
-
- *num_overridden = Overridden.size();
- *overridden = new CXCursor [Overridden.size()];
- std::copy(Overridden.begin(), Overridden.end(), *overridden);
-}
-
-void clang_disposeOverriddenCursors(CXCursor *overridden) {
- delete [] overridden;
-}
-
CXFile clang_getIncludedFile(CXCursor cursor) {
if (cursor.kind != CXCursor_InclusionDirective)
return 0;
Modified: cfe/branches/tooling/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CXCursor.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CXCursor.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CXCursor.cpp Tue May 8 03:47:31 2012
@@ -30,9 +30,9 @@
using namespace clang;
using namespace cxcursor;
-CXCursor cxcursor::MakeCXCursorInvalid(CXCursorKind K) {
+CXCursor cxcursor::MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU) {
assert(K >= CXCursor_FirstInvalid && K <= CXCursor_LastInvalid);
- CXCursor C = { K, 0, { 0, 0, 0 } };
+ CXCursor C = { K, 0, { 0, 0, TU } };
return C;
}
@@ -1152,5 +1152,106 @@
}
return NULL;
}
+} // end: extern C.
+
+namespace {
+ struct OverridenCursorsPool {
+ typedef llvm::SmallVector<CXCursor, 2> CursorVec;
+ std::vector<CursorVec*> AllCursors;
+ std::vector<CursorVec*> AvailableCursors;
+
+ ~OverridenCursorsPool() {
+ for (std::vector<CursorVec*>::iterator I = AllCursors.begin(),
+ E = AllCursors.end(); I != E; ++I) {
+ delete *I;
+ }
+ }
+ };
+}
+
+void *cxcursor::createOverridenCXCursorsPool() {
+ return new OverridenCursorsPool();
+}
+
+void cxcursor::disposeOverridenCXCursorsPool(void *pool) {
+ delete static_cast<OverridenCursorsPool*>(pool);
+}
+
+extern "C" {
+void clang_getOverriddenCursors(CXCursor cursor,
+ CXCursor **overridden,
+ unsigned *num_overridden) {
+ if (overridden)
+ *overridden = 0;
+ if (num_overridden)
+ *num_overridden = 0;
+
+ CXTranslationUnit TU = cxcursor::getCursorTU(cursor);
+
+ if (!overridden || !num_overridden || !TU)
+ return;
+
+ if (!clang_isDeclaration(cursor.kind))
+ return;
+
+ OverridenCursorsPool &pool =
+ *static_cast<OverridenCursorsPool*>(TU->OverridenCursorsPool);
+
+ OverridenCursorsPool::CursorVec *Vec = 0;
+
+ if (!pool.AvailableCursors.empty()) {
+ Vec = pool.AvailableCursors.back();
+ pool.AvailableCursors.pop_back();
+ }
+ else {
+ Vec = new OverridenCursorsPool::CursorVec();
+ pool.AllCursors.push_back(Vec);
+ }
+
+ // Clear out the vector, but don't free the memory contents. This
+ // reduces malloc() traffic.
+ Vec->clear();
+
+ // Use the first entry to contain a back reference to the vector.
+ // This is a complete hack.
+ CXCursor backRefCursor = MakeCXCursorInvalid(CXCursor_InvalidFile, TU);
+ backRefCursor.data[0] = Vec;
+ assert(cxcursor::getCursorTU(backRefCursor) == TU);
+ Vec->push_back(backRefCursor);
+
+ // Get the overriden cursors.
+ cxcursor::getOverriddenCursors(cursor, *Vec);
+
+ // Did we get any overriden cursors? If not, return Vec to the pool
+ // of available cursor vectors.
+ if (Vec->size() == 1) {
+ pool.AvailableCursors.push_back(Vec);
+ return;
+ }
+
+ // Now tell the caller about the overriden cursors.
+ assert(Vec->size() > 1);
+ *overridden = &((*Vec)[1]);
+ *num_overridden = Vec->size() - 1;
+}
+
+void clang_disposeOverriddenCursors(CXCursor *overridden) {
+ if (!overridden)
+ return;
+
+ // Use pointer arithmetic to get back the first faux entry
+ // which has a back-reference to the TU and the vector.
+ --overridden;
+ OverridenCursorsPool::CursorVec *Vec =
+ static_cast<OverridenCursorsPool::CursorVec*>(overridden->data[0]);
+ CXTranslationUnit TU = getCursorTU(*overridden);
+
+ assert(Vec && TU);
+
+ OverridenCursorsPool &pool =
+ *static_cast<OverridenCursorsPool*>(TU->OverridenCursorsPool);
+
+ pool.AvailableCursors.push_back(Vec);
+}
} // end: extern "C"
Modified: cfe/branches/tooling/tools/libclang/CXCursor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CXCursor.h?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CXCursor.h (original)
+++ cfe/branches/tooling/tools/libclang/CXCursor.h Tue May 8 03:47:31 2012
@@ -55,7 +55,7 @@
CXCursor MakeCXCursor(clang::Stmt *S, clang::Decl *Parent,
CXTranslationUnit TU,
SourceRange RegionOfInterest = SourceRange());
-CXCursor MakeCXCursorInvalid(CXCursorKind K);
+CXCursor MakeCXCursorInvalid(CXCursorKind K, CXTranslationUnit TU = 0);
/// \brief Create an Objective-C superclass reference at the given location.
CXCursor MakeCursorObjCSuperClassRef(ObjCInterfaceDecl *Super,
@@ -206,8 +206,15 @@
CXTranslationUnit getCursorTU(CXCursor Cursor);
void getOverriddenCursors(CXCursor cursor,
- SmallVectorImpl<CXCursor> &overridden);
+ SmallVectorImpl<CXCursor> &overridden);
+
+/// \brief Create an opaque pool used for fast generation of overriden
+/// CXCursor arrays.
+void *createOverridenCXCursorsPool();
+/// \brief Dispose of the overriden CXCursors pool.
+void disposeOverridenCXCursorsPool(void *pool);
+
/// \brief Returns a index/location pair for a selector identifier if the cursor
/// points to one.
std::pair<int, SourceLocation> getSelectorIdentifierIndexAndLoc(CXCursor);
Modified: cfe/branches/tooling/tools/libclang/CXTranslationUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CXTranslationUnit.h?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CXTranslationUnit.h (original)
+++ cfe/branches/tooling/tools/libclang/CXTranslationUnit.h Tue May 8 03:47:31 2012
@@ -20,6 +20,7 @@
void *TUData;
void *StringPool;
void *Diagnostics;
+ void *OverridenCursorsPool;
};
}
Modified: cfe/branches/tooling/tools/libclang/CXType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/CXType.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/CXType.cpp (original)
+++ cfe/branches/tooling/tools/libclang/CXType.cpp Tue May 8 03:47:31 2012
@@ -94,7 +94,22 @@
CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) {
- CXTypeKind TK = GetTypeKind(T);
+ CXTypeKind TK = CXType_Invalid;
+
+ if (TU) {
+ ASTContext &Ctx = static_cast<ASTUnit *>(TU->TUData)->getASTContext();
+ if (Ctx.getLangOpts().ObjC1) {
+ if (Ctx.isObjCIdType(T))
+ TK = CXType_ObjCId;
+ else if (Ctx.isObjCClassType(T))
+ TK = CXType_ObjCClass;
+ else if (Ctx.isObjCSelType(T))
+ TK = CXType_ObjCSel;
+ }
+ }
+ if (TK == CXType_Invalid)
+ TK = GetTypeKind(T);
+
CXType CT = { TK, { TK == CXType_Invalid ? 0 : T.getAsOpaquePtr(), TU }};
return CT;
}
Modified: cfe/branches/tooling/tools/libclang/IndexBody.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexBody.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexBody.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexBody.cpp Tue May 8 03:47:31 2012
@@ -9,14 +9,14 @@
#include "IndexingContext.h"
-#include "clang/AST/RecursiveASTVisitor.h"
+#include "RecursiveASTVisitor.h"
using namespace clang;
using namespace cxindex;
namespace {
-class BodyIndexer : public RecursiveASTVisitor<BodyIndexer> {
+class BodyIndexer : public cxindex::RecursiveASTVisitor<BodyIndexer> {
IndexingContext &IndexCtx;
const NamedDecl *Parent;
const DeclContext *ParentDC;
Modified: cfe/branches/tooling/tools/libclang/IndexTypeSourceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/IndexTypeSourceInfo.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/IndexTypeSourceInfo.cpp (original)
+++ cfe/branches/tooling/tools/libclang/IndexTypeSourceInfo.cpp Tue May 8 03:47:31 2012
@@ -9,14 +9,14 @@
#include "IndexingContext.h"
-#include "clang/AST/RecursiveASTVisitor.h"
+#include "RecursiveASTVisitor.h"
using namespace clang;
using namespace cxindex;
namespace {
-class TypeIndexer : public RecursiveASTVisitor<TypeIndexer> {
+class TypeIndexer : public cxindex::RecursiveASTVisitor<TypeIndexer> {
IndexingContext &IndexCtx;
const NamedDecl *Parent;
const DeclContext *ParentDC;
Modified: cfe/branches/tooling/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/tools/libclang/libclang.exports?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/tools/libclang/libclang.exports (original)
+++ cfe/branches/tooling/tools/libclang/libclang.exports Tue May 8 03:47:31 2012
@@ -43,6 +43,7 @@
clang_disposeDiagnosticSet
clang_disposeIndex
clang_disposeOverriddenCursors
+clang_disposeCXPlatformAvailability
clang_disposeString
clang_disposeTokens
clang_disposeTranslationUnit
@@ -85,6 +86,7 @@
clang_getCursorLexicalParent
clang_getCursorLinkage
clang_getCursorLocation
+clang_getCursorPlatformAvailability
clang_getCursorReferenceNameRange
clang_getCursorReferenced
clang_getCursorResultType
Modified: cfe/branches/tooling/unittests/Tooling/RecursiveASTVisitorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/unittests/Tooling/RecursiveASTVisitorTest.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/unittests/Tooling/RecursiveASTVisitorTest.cpp (original)
+++ cfe/branches/tooling/unittests/Tooling/RecursiveASTVisitorTest.cpp Tue May 8 03:47:31 2012
@@ -1,4 +1,4 @@
-//===- unittest/AST/RecursiveASTMatcherTest.cpp ---------------------------===//
+//===- unittest/Tooling/RecursiveASTVisitorTest.cpp -----------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -165,6 +165,26 @@
}
};
+class CXXOperatorCallExprTraverser
+ : public ExpectedLocationVisitor<CXXOperatorCallExprTraverser> {
+public:
+ // Use Traverse, not Visit, to check that data recursion optimization isn't
+ // bypassing the call of this function.
+ bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *CE) {
+ Match(getOperatorSpelling(CE->getOperator()), CE->getExprLoc());
+ return ExpectedLocationVisitor<CXXOperatorCallExprTraverser>::
+ TraverseCXXOperatorCallExpr(CE);
+ }
+};
+
+class ParenExprVisitor : public ExpectedLocationVisitor<ParenExprVisitor> {
+public:
+ bool VisitParenExpr(ParenExpr *Parens) {
+ Match("", Parens->getExprLoc());
+ return true;
+ }
+};
+
TEST(RecursiveASTVisitor, VisitsBaseClassDeclarations) {
TypeLocVisitor Visitor;
Visitor.ExpectMatch("class X", 1, 30);
@@ -345,4 +365,20 @@
"vector_iterator<int> it_int;\n"));
}
+TEST(RecursiveASTVisitor, TraversesOverloadedOperator) {
+ CXXOperatorCallExprTraverser Visitor;
+ Visitor.ExpectMatch("()", 4, 9);
+ EXPECT_TRUE(Visitor.runOver(
+ "struct A {\n"
+ " int operator()();\n"
+ "} a;\n"
+ "int k = a();\n"));
+}
+
+TEST(RecursiveASTVisitor, VisitsParensDuringDataRecursion) {
+ ParenExprVisitor Visitor;
+ Visitor.ExpectMatch("", 1, 9);
+ EXPECT_TRUE(Visitor.runOver("int k = (4) + 9;\n"));
+}
+
} // end namespace clang
Modified: cfe/branches/tooling/utils/TableGen/ClangAttrEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangAttrEmitter.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/ClangAttrEmitter.cpp Tue May 8 03:47:31 2012
@@ -14,6 +14,7 @@
#include "ClangAttrEmitter.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringMatcher.h"
#include <algorithm>
#include <cctype>
#include <set>
@@ -670,6 +671,10 @@
for (std::vector<Record*>::iterator i = Attrs.begin(), e = Attrs.end();
i != e; ++i) {
Record &R = **i;
+
+ if (!R.getValueAsBit("ASTNode"))
+ continue;
+
const std::string &SuperName = R.getSuperClasses().back()->getName();
OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n";
@@ -754,6 +759,10 @@
for (; i != e; ++i) {
Record &R = **i;
+
+ if (!R.getValueAsBit("ASTNode"))
+ continue;
+
std::vector<Record*> ArgRecords = R.getValueAsListOfDefs("Args");
std::vector<StringRef> Spellings = getValueAsListOfStrings(R, "Spellings");
std::vector<Argument*> Args;
@@ -798,8 +807,12 @@
if (i != e) {
// Move the end iterator back to emit the last attribute.
- for(--e; i != e; ++i)
+ for(--e; i != e; ++i) {
+ if (!(*i)->getValueAsBit("ASTNode"))
+ continue;
+
OS << Class << "(" << (*i)->getName() << ")\n";
+ }
OS << "LAST_" << Class << "(" << (*i)->getName() << ")\n\n";
}
@@ -835,6 +848,9 @@
NonInhAttrs, InhAttrs, InhParamAttrs;
for (std::vector<Record*>::iterator i = Attrs.begin(), e = Attrs.end();
i != e; ++i) {
+ if (!(*i)->getValueAsBit("ASTNode"))
+ continue;
+
if ((*i)->isSubClassOf(InhParamClass))
InhParamAttrs.push_back(*i);
else if ((*i)->isSubClassOf(InhClass))
@@ -870,6 +886,9 @@
OS << " break;\n";
for (; i != e; ++i) {
Record &R = **i;
+ if (!R.getValueAsBit("ASTNode"))
+ continue;
+
OS << " case attr::" << R.getName() << ": {\n";
if (R.isSubClassOf(InhClass))
OS << " bool isInherited = Record[Idx++];\n";
@@ -905,6 +924,8 @@
OS << " break;\n";
for (; i != e; ++i) {
Record &R = **i;
+ if (!R.getValueAsBit("ASTNode"))
+ continue;
OS << " case attr::" << R.getName() << ": {\n";
Args = R.getValueAsListOfDefs("Args");
if (R.isSubClassOf(InhClass) || !Args.empty())
@@ -979,6 +1000,8 @@
for (std::vector<Record*>::iterator I = Attrs.begin(), E = Attrs.end();
I != E; ++I) {
Record &R = **I;
+ if (!R.getValueAsBit("ASTNode"))
+ continue;
OS << " case attr::" << R.getName() << ": {\n";
OS << " const " << R.getName() << "Attr *A = cast<"
@@ -1063,30 +1086,47 @@
void ClangAttrParsedAttrKindsEmitter::run(raw_ostream &OS) {
OS << "// This file is generated by TableGen. Do not edit.\n\n";
-
+ OS << "\n";
+
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
+ std::vector<StringMatcher::StringPair> Matches;
for (std::vector<Record*>::iterator I = Attrs.begin(), E = Attrs.end();
I != E; ++I) {
Record &Attr = **I;
bool SemaHandler = Attr.getValueAsBit("SemaHandler");
+ bool Ignored = Attr.getValueAsBit("Ignored");
- if (SemaHandler) {
+ if (SemaHandler || Ignored) {
std::vector<StringRef> Spellings =
getValueAsListOfStrings(Attr, "Spellings");
for (std::vector<StringRef>::const_iterator I = Spellings.begin(),
E = Spellings.end(); I != E; ++I) {
- StringRef AttrName = *I, Spelling = *I;
+ StringRef AttrName = *I, Spelling = *I;
- AttrName = NormalizeAttrName(AttrName);
- Spelling = NormalizeAttrSpelling(Spelling);
+ AttrName = NormalizeAttrName(AttrName);
+ Spelling = NormalizeAttrSpelling(Spelling);
- OS << ".Case(\"" << Spelling << "\", " << "AT_" << AttrName << ")\n";
+ if (SemaHandler)
+ Matches.push_back(
+ StringMatcher::StringPair(Spelling,
+ std::string("return AttributeList::AT_") +
+ AttrName.str() + ";"));
+ else
+ Matches.push_back(
+ StringMatcher::StringPair(
+ Spelling,
+ std::string("return AttributeList::IgnoredAttribute;")));
}
}
}
+
+ OS << "static AttributeList::Kind getAttrKind(StringRef Name) {\n";
+ StringMatcher("Name", Matches, OS).Emit();
+ OS << "return AttributeList::UnknownAttribute;\n"
+ << "}\n";
}
Modified: cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=156378&r1=156377&r2=156378&view=diff
==============================================================================
--- cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ cfe/branches/tooling/utils/TableGen/ClangDiagnosticsEmitter.cpp Tue May 8 03:47:31 2012
@@ -135,6 +135,8 @@
const Record *R = Diags[i];
DefInit *DI = dynamic_cast<DefInit*>(R->getValueInit("Group"));
if (DI == 0) continue;
+ assert(R->getValueAsDef("Class")->getName() != "CLASS_NOTE" &&
+ "Note can't be in a DiagGroup");
std::string GroupName = DI->getDef()->getValueAsString("GroupName");
DiagsInGroup[GroupName].DiagsInGroup.push_back(R);
}
More information about the llvm-branch-commits
mailing list