[cfe-commits] r48358 - /cfe/trunk/Driver/clang.cpp
Chris Lattner
sabre at nondot.org
Thu Mar 13 23:12:06 PDT 2008
Author: lattner
Date: Fri Mar 14 01:12:05 2008
New Revision: 48358
URL: http://llvm.org/viewvc/llvm-project?rev=48358&view=rev
Log:
Only compute targetinfo once and don't leak it. Patch by Sam Bishop!
Modified:
cfe/trunk/Driver/clang.cpp
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=48358&r1=48357&r2=48358&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Fri Mar 14 01:12:05 2008
@@ -1262,6 +1262,16 @@
--i;
}
}
+
+ // Get information about the target being compiled for.
+ std::string Triple = CreateTargetTriple();
+ TargetInfo *Target = TargetInfo::CreateTargetInfo(Triple);
+ if (Target == 0) {
+ fprintf(stderr, "Sorry, I don't know what target this is: %s\n",
+ Triple.c_str());
+ fprintf(stderr, "Please use -triple or -arch.\n");
+ exit(1);
+ }
for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
const std::string &InFile = InputFilenames[i];
@@ -1285,19 +1295,6 @@
DiagClient->setHeaderSearch(HeaderInfo);
InitializeIncludePaths(argv[0], HeaderInfo, FileMgr, LangInfo);
- // Get information about the targets being compiled for. Note that this
- // pointer and the TargetInfoImpl objects are never deleted by this toy
- // driver.
- std::string Triple = CreateTargetTriple();
- TargetInfo *Target = TargetInfo::CreateTargetInfo(Triple);
-
- if (Target == 0) {
- fprintf(stderr, "Sorry, I don't know what target this is: %s\n",
- Triple.c_str());
- fprintf(stderr, "Please use -triple or -arch.\n");
- exit(1);
- }
-
// Set up the preprocessor with these options.
Preprocessor PP(Diags, LangInfo, *Target, SourceMgr, HeaderInfo);
@@ -1313,6 +1310,8 @@
}
}
+ delete Target;
+
unsigned NumDiagnostics = Diags.getNumDiagnostics();
if (NumDiagnostics)
More information about the cfe-commits
mailing list