[cfe-commits] r79782 - in /cfe/trunk: include/clang/Basic/DiagnosticFrontendKinds.td include/clang/Basic/LangOptions.h lib/CodeGen/CGCXX.cpp lib/Frontend/PCHReader.cpp lib/Frontend/PCHWriter.cpp tools/clang-cc/clang-cc.cpp
Anders Carlsson
andersca at mac.com
Sat Aug 22 15:30:34 PDT 2009
Author: andersca
Date: Sat Aug 22 17:30:33 2009
New Revision: 79782
URL: http://llvm.org/viewvc/llvm-project?rev=79782&view=rev
Log:
Add a -fno-elide-constructors option to clang-cc.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=79782&r1=79781&r2=79782&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Sat Aug 22 17:30:33 2009
@@ -70,6 +70,9 @@
def warn_pch_opencl : Error<
"OpenCL language extensions were %select{disabled|enabled}0 in PCH file "
"but are currently %select{disabled|enabled}1">;
+ def warn_elide_constructors : Error<
+ "Elidable copy constructors were %select{disabled|enabled}0 in PCH file "
+ "but are currently %select{disabled|enabled}1">;
def warn_pch_exceptions : Error<
"exceptions were %select{disabled|enabled}0 in PCH file but "
"are currently %select{disabled|enabled}1">;
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=79782&r1=79781&r2=79782&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Sat Aug 22 17:30:33 2009
@@ -86,6 +86,8 @@
unsigned OpenCL : 1; // OpenCL C99 language extensions.
+ unsigned ElideConstructors : 1; // Whether C++ copy constructors should be
+ // elided if possible.
private:
unsigned GC : 2; // Objective-C Garbage Collection modes. We
// declare this enum as unsigned because MSVC
@@ -136,6 +138,7 @@
// FIXME: The default should be 1.
AccessControl = 0;
+ ElideConstructors = 1;
OverflowChecking = 0;
ObjCGCBitmapPrint = 0;
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=79782&r1=79781&r2=79782&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Sat Aug 22 17:30:33 2009
@@ -512,7 +512,7 @@
// Code gen optimization to eliminate copy constructor and return
// its first argument instead.
- if (E->isElidable()) {
+ if (getContext().getLangOptions().ElideConstructors && E->isElidable()) {
CXXConstructExpr::const_arg_iterator i = E->arg_begin();
EmitAggExpr((*i), Dest, false);
return;
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=79782&r1=79781&r2=79782&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Sat Aug 22 17:30:33 2009
@@ -107,6 +107,7 @@
PARSE_LANGOPT_BENIGN(getVisibilityMode());
PARSE_LANGOPT_BENIGN(InstantiationDepth);
PARSE_LANGOPT_IMPORTANT(OpenCL, diag::warn_pch_opencl);
+ PARSE_LANGOPT_IMPORTANT(ElideConstructors, diag::warn_elide_constructors);
#undef PARSE_LANGOPT_IRRELEVANT
#undef PARSE_LANGOPT_BENIGN
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=79782&r1=79781&r2=79782&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Sat Aug 22 17:30:33 2009
@@ -621,6 +621,7 @@
Record.push_back(LangOpts.getVisibilityMode());
Record.push_back(LangOpts.InstantiationDepth);
Record.push_back(LangOpts.OpenCL);
+ Record.push_back(LangOpts.ElideConstructors);
Stream.EmitRecord(pch::LANGUAGE_OPTIONS, Record);
}
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=79782&r1=79781&r2=79782&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Sat Aug 22 17:30:33 2009
@@ -651,6 +651,11 @@
AccessControl("faccess-control",
llvm::cl::desc("Enable C++ access control"));
+static llvm::cl::opt<bool>
+NoElideConstructors("fno-elide-constructors",
+ llvm::cl::desc("Disable C++ copy constructor elision"));
+
+
// It might be nice to add bounds to the CommandLine library directly.
struct OptLevelParser : public llvm::cl::parser<unsigned> {
bool parse(llvm::cl::Option &O, const char *ArgName,
@@ -798,6 +803,8 @@
if (AccessControl)
Options.AccessControl = 1;
+ Options.ElideConstructors = !NoElideConstructors;
+
// OpenCL and C++ both have bool, true, false keywords.
Options.Bool = Options.OpenCL | Options.CPlusPlus;
More information about the cfe-commits
mailing list