diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-03-14 06:12:05 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-03-14 06:12:05 +0000 |
| commit | e8ec2806272c45d1ef7c25945411b4e7625b76f7 (patch) | |
| tree | a9e1fe4942644c2c5424b1af4f04040c5cf13708 /clang/Driver/clang.cpp | |
| parent | 221929310b192abc79140318fb9801760e76a928 (diff) | |
| download | bcm5719-llvm-e8ec2806272c45d1ef7c25945411b4e7625b76f7.tar.gz bcm5719-llvm-e8ec2806272c45d1ef7c25945411b4e7625b76f7.zip | |
Only compute targetinfo once and don't leak it. Patch by Sam Bishop!
llvm-svn: 48358
Diffstat (limited to 'clang/Driver/clang.cpp')
| -rw-r--r-- | clang/Driver/clang.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp index 5f3f168ff79..c004d9d6b1c 100644 --- a/clang/Driver/clang.cpp +++ b/clang/Driver/clang.cpp @@ -1262,6 +1262,16 @@ int main(int argc, char **argv) { --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 @@ int main(int argc, char **argv) { 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 @@ int main(int argc, char **argv) { } } + delete Target; + unsigned NumDiagnostics = Diags.getNumDiagnostics(); if (NumDiagnostics) |

