]> granicus.if.org Git - clang/commitdiff
Reland r160052: Default to -std=c++11 on Windows.
authorNico Weber <nicolasweber@gmx.de>
Thu, 30 Aug 2012 02:08:31 +0000 (02:08 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 30 Aug 2012 02:08:31 +0000 (02:08 +0000)
Also update the tests that rely on c++98 to explicitly mention that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162890 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Index/complete-cxx-inline-methods.cpp
test/Index/recursive-cxx-member-calls.cpp
test/SemaTemplate/inject-templated-friend-post.cpp
unittests/AST/DeclPrinterTest.cpp
unittests/ASTMatchers/ASTMatchersTest.h

index c113406670ba6bec21218877bfca53a5ec43e0ae..3c46e34ac78f432f3673d9ca21fd58d2afec2462 100644 (file)
@@ -2141,8 +2141,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
     // eventually we want to do all the standard defaulting here instead of
     // splitting it between the driver and clang -cc1.
     if (!types::isCXX(InputType))
-        Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ,
-                                  "-std=", /*Joined=*/true);
+      Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ,
+                                "-std=", /*Joined=*/true);
+    else if (getToolChain().getTriple().getOS() == llvm::Triple::Win32)
+      CmdArgs.push_back("-std=c++11");
+
     Args.AddLastArg(CmdArgs, options::OPT_trigraphs);
   }
 
index d441972dd6feeb719241a45038e70f9ac0e66a32..ee359f75e4455e48094457d1f32fa82109f15ee0 100644 (file)
@@ -23,8 +23,8 @@ private:
 };
 }
 
-// RUN: c-index-test -code-completion-at=%s:4:9 %s | FileCheck %s
-// RUN: c-index-test -code-completion-at=%s:13:7 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s
 // CHECK:      CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34)
 // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
index 9b93872ee01b5b8fb04de9c0b4f9d6ef5db2cd6d..501dc2954f023ec21d47e6d26afb49eaa7cff5e8 100644 (file)
@@ -1523,7 +1523,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
 // CHECK-tokens: Punctuation: ";" [185:31 - 185:32] CompoundStmt=
 // CHECK-tokens: Punctuation: "}" [186:1 - 186:2] CompoundStmt=
 
-// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s
+// RUN: c-index-test -test-load-source all %s -std=c++98 2>&1 | FileCheck %s
 // CHECK: 1:27: TypedefDecl=__darwin_size_t:1:27 (Definition) Extent=[1:1 - 1:42]
 // CHECK: 2:25: TypedefDecl=size_t:2:25 (Definition) Extent=[2:1 - 2:31]
 // CHECK: 2:9: TypeRef=__darwin_size_t:1:27 Extent=[2:9 - 2:24]
index 39c445ca0f996ec70a62ce550c05845fe2bb64af..c86f718bb5f1c84c8ee8328c3a4041047c0a1328 100644 (file)
@@ -1,7 +1,7 @@
-// RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
-// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
-// RUN: %clang %s -S -emit-llvm -o - -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
-// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -std=c++98 -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -std=c++98 -S -emit-llvm -o - -DPROTOTYPE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -std=c++98 -S -emit-llvm -o - -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
+// RUN: %clang %s -std=c++98 -S -emit-llvm -o - -DPROTOTYPE -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE"
 // RUN: %clang_cc1 %s -DREDEFINE -verify
 // RUN: %clang_cc1 %s -DPROTOTYPE -DREDEFINE -verify
 // PR8007: friend function not instantiated, reordered version.
index c99550af226716b0652948ac39a7f3966b35be9f..2800df4caf5de0c79d7cdffd6fb618d8c6eb9b7a 100644 (file)
@@ -73,6 +73,8 @@ bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code,
   std::vector<std::string> ArgVector;
   ArgVector.push_back("clang-tool");
   ArgVector.push_back("-fsyntax-only");
+  // operator delete (void*) grows a "noexcept" in c++11.
+  ArgVector.push_back("-std=c++98");
   ArgVector.push_back(FileNameRef.data());
   for (unsigned i = 0, e = ClangArgs.size(); i != e; ++i)
     ArgVector.push_back(ClangArgs[i]);
index 64816f5d60468be6d14603e44f0cfcb3dac4a00b..6d872e8ea990934f85f9ba3a32a9abe6d78ae30e 100644 (file)
@@ -18,7 +18,7 @@ namespace clang {
 namespace ast_matchers {
 
 using clang::tooling::newFrontendActionFactory;
-using clang::tooling::runToolOnCode;
+using clang::tooling::runToolOnCodeWithArgs;
 using clang::tooling::FrontendActionFactory;
 
 class BoundNodesCallback {
@@ -56,7 +56,9 @@ testing::AssertionResult matchesConditionally(const std::string &Code,
   MatchFinder Finder;
   Finder.addMatcher(AMatcher, new VerifyMatch(0, &Found));
   OwningPtr<FrontendActionFactory> Factory(newFrontendActionFactory(&Finder));
-  if (!runToolOnCode(Factory->create(), Code)) {
+  // Some tests use typeof, which is a gnu extension.
+  std::vector<std::string> Args(1, "-std=gnu++98");
+  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) {
     return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
   }
   if (!Found && ExpectMatch) {
@@ -91,7 +93,9 @@ matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher,
   Finder.addMatcher(
       AMatcher, new VerifyMatch(FindResultVerifier, &VerifiedResult));
   OwningPtr<FrontendActionFactory> Factory(newFrontendActionFactory(&Finder));
-  if (!runToolOnCode(Factory->create(), Code)) {
+  // Some tests use typeof, which is a gnu extension.
+  std::vector<std::string> Args(1, "-std=gnu++98");
+  if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) {
     return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
   }
   if (!VerifiedResult && ExpectResult) {